Skip to content

Commit

Permalink
tests for storedSource updates
Browse files Browse the repository at this point in the history
  • Loading branch information
lantoli committed Jul 11, 2024
1 parent 1116813 commit 9acf92b
Showing 1 changed file with 21 additions and 35 deletions.
56 changes: 21 additions & 35 deletions internal/service/searchindex/resource_search_index_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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"),
},
},
}
Expand Down

0 comments on commit 9acf92b

Please sign in to comment.