From 9acf92baa898b207f063a771cc74d8605d6d0d7a Mon Sep 17 00:00:00 2001 From: Leo Antoli <430982+lantoli@users.noreply.github.com> Date: Thu, 11 Jul 2024 10:29:02 +0200 Subject: [PATCH] tests for storedSource updates --- .../searchindex/resource_search_index_test.go | 56 +++++++------------ 1 file changed, 21 insertions(+), 35 deletions(-) diff --git a/internal/service/searchindex/resource_search_index_test.go b/internal/service/searchindex/resource_search_index_test.go index f61db698db..6bca66ff9b 100644 --- a/internal/service/searchindex/resource_search_index_test.go +++ b/internal/service/searchindex/resource_search_index_test.go @@ -193,53 +193,35 @@ func TestAccSearchIndex_withStoredSourceExclude(t *testing.T) { resource.ParallelTest(t, *storedSourceTestCase(t, storedSourceExcludeJSON)) } -func TestAccSearchIndex_withStoredSourceUpdate(t *testing.T) { - var ( - projectID, clusterName = acc.ClusterNameExecution(t) - indexName = acc.RandomName() - databaseName = acc.RandomName() - ) - resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { acc.PreCheckBasic(t) }, - ProtoV6ProviderFactories: acc.TestAccProviderV6Factories, - CheckDestroy: acc.CheckDestroySearchIndex, - Steps: []resource.TestStep{ - { - Config: configBasic(projectID, clusterName, indexName, "", databaseName, "false"), - Check: checkBasic(projectID, clusterName, indexName, "", databaseName, "false"), - }, - { - Config: configBasic(projectID, clusterName, indexName, "", databaseName, "true"), - Check: checkBasic(projectID, clusterName, indexName, "", databaseName, "true"), - }, - }, - }) +func TestAccSearchIndex_withStoredSourceUpdateEmptyType(t *testing.T) { + resource.ParallelTest(t, *storedSourceTestCaseUpdate(t, "search")) +} + +func TestAccSearchIndex_withStoredSourceUpdateSearchType(t *testing.T) { + resource.ParallelTest(t, *storedSourceTestCaseUpdate(t, "")) } -func TestAccSearchIndex_withStoredSourceUpdateTEMPORARY_INVALID(t *testing.T) { +func storedSourceTestCase(tb testing.TB, storedSource string) *resource.TestCase { + tb.Helper() var ( - projectID, clusterName = acc.ClusterNameExecution(t) + projectID, clusterName = acc.ClusterNameExecution(tb) indexName = acc.RandomName() databaseName = acc.RandomName() ) - resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { acc.PreCheckBasic(t) }, + return &resource.TestCase{ + PreCheck: func() { acc.PreCheckBasic(tb) }, ProtoV6ProviderFactories: acc.TestAccProviderV6Factories, CheckDestroy: acc.CheckDestroySearchIndex, Steps: []resource.TestStep{ { - Config: configBasic(projectID, clusterName, indexName, "search", databaseName, "false"), - Check: checkBasic(projectID, clusterName, indexName, "search", databaseName, "false"), - }, - { - Config: configBasic(projectID, clusterName, indexName, "search", databaseName, "true"), - Check: checkBasic(projectID, clusterName, indexName, "search", databaseName, "true"), + Config: configBasic(projectID, clusterName, indexName, "search", databaseName, storedSource), + Check: checkBasic(projectID, clusterName, indexName, "search", databaseName, storedSource), }, }, - }) + } } -func storedSourceTestCase(tb testing.TB, storedSource string) *resource.TestCase { +func storedSourceTestCaseUpdate(tb testing.TB, searchType string) *resource.TestCase { tb.Helper() var ( projectID, clusterName = acc.ClusterNameExecution(tb) @@ -252,8 +234,12 @@ func storedSourceTestCase(tb testing.TB, storedSource string) *resource.TestCase CheckDestroy: acc.CheckDestroySearchIndex, Steps: []resource.TestStep{ { - Config: configBasic(projectID, clusterName, indexName, "search", databaseName, storedSource), - Check: checkBasic(projectID, clusterName, indexName, "search", databaseName, storedSource), + Config: configBasic(projectID, clusterName, indexName, searchType, databaseName, "false"), + Check: checkBasic(projectID, clusterName, indexName, searchType, databaseName, "false"), + }, + { + Config: configBasic(projectID, clusterName, indexName, searchType, databaseName, "true"), + Check: checkBasic(projectID, clusterName, indexName, searchType, databaseName, "true"), }, }, }