@@ -14,12 +14,11 @@ import (
14
14
15
15
func TestAccResourceMongoDBAtlasSearchIndex_basic (t * testing.T ) {
16
16
var (
17
- index matlas.SearchIndex
18
- resourceName = "mongodbatlas_search_index.test"
19
- clusterName = acctest .RandomWithPrefix ("test-acc-index" )
20
- projectID = os .Getenv ("MONGODB_ATLAS_PROJECT_ID" )
21
- name = "name_test"
22
- updatedAnalyzer = "lucene.simple"
17
+ index matlas.SearchIndex
18
+ resourceName = "mongodbatlas_search_index.test"
19
+ clusterName = acctest .RandomWithPrefix ("test-acc-index" )
20
+ projectID = os .Getenv ("MONGODB_ATLAS_PROJECT_ID" )
21
+ name = "name_test"
23
22
)
24
23
resource .ParallelTest (t , resource.TestCase {
25
24
PreCheck : func () { testAccPreCheck (t ) },
@@ -35,6 +34,24 @@ func TestAccResourceMongoDBAtlasSearchIndex_basic(t *testing.T) {
35
34
resource .TestCheckResourceAttr (resourceName , "cluster_name" , clusterName ),
36
35
),
37
36
},
37
+ },
38
+ })
39
+ }
40
+
41
+ func TestAccResourceMongoDBAtlasSearchIndex_withMapping (t * testing.T ) {
42
+ var (
43
+ index matlas.SearchIndex
44
+ resourceName = "mongodbatlas_search_index.test"
45
+ clusterName = acctest .RandomWithPrefix ("test-acc-index" )
46
+ projectID = os .Getenv ("MONGODB_ATLAS_PROJECT_ID" )
47
+ name = "name_test"
48
+ updatedAnalyzer = "lucene.simple"
49
+ )
50
+ resource .ParallelTest (t , resource.TestCase {
51
+ PreCheck : func () { testAccPreCheck (t ) },
52
+ Providers : testAccProviders ,
53
+ CheckDestroy : testAccCheckMongoDBAtlasSearchIndexDestroy ,
54
+ Steps : []resource.TestStep {
38
55
{
39
56
Config : testAccMongoDBAtlasSearchIndexConfigAdvanced (projectID , clusterName ),
40
57
Check : resource .ComposeTestCheckFunc (
@@ -52,25 +69,28 @@ func TestAccResourceMongoDBAtlasSearchIndex_basic(t *testing.T) {
52
69
53
70
func TestAccResourceMongoDBAtlasSearchIndex_importBasic (t * testing.T ) {
54
71
var (
72
+ index matlas.SearchIndex
55
73
resourceName = "mongodbatlas_search_index.test"
56
- clusterName = acctest .RandomWithPrefix ("test-acc-global " )
74
+ clusterName = acctest .RandomWithPrefix ("test-acc-index " )
57
75
projectID = os .Getenv ("MONGODB_ATLAS_PROJECT_ID" )
76
+ name = "name_test"
58
77
)
59
-
60
78
resource .ParallelTest (t , resource.TestCase {
61
79
PreCheck : func () { testAccPreCheck (t ) },
62
80
Providers : testAccProviders ,
63
81
CheckDestroy : testAccCheckMongoDBAtlasSearchIndexDestroy ,
64
82
Steps : []resource.TestStep {
65
83
{
66
- Config : testAccMongoDBAtlasSearchIndexConfig (projectID , clusterName ),
67
- ResourceName : resourceName ,
68
- ImportStateIdFunc : testAccCheckMongoDBAtlasSearchIndexImportStateIDFunc (resourceName ),
69
- ImportState : true ,
70
- ImportStateVerify : true ,
84
+ Config : testAccMongoDBAtlasSearchIndexConfig (projectID , clusterName ),
85
+ Check : resource .ComposeTestCheckFunc (
86
+ testAccCheckMongoDBAtlasSearchIndexExists (resourceName , & index ),
87
+ resource .TestCheckResourceAttr (resourceName , "name" , name ),
88
+ resource .TestCheckResourceAttr (resourceName , "project_id" , projectID ),
89
+ resource .TestCheckResourceAttr (resourceName , "cluster_name" , clusterName ),
90
+ ),
71
91
},
72
92
{
73
- Config : testAccMongoDBAtlasSearchIndexConfigAdvanced (projectID , clusterName ),
93
+ Config : testAccMongoDBAtlasSearchIndexConfig (projectID , clusterName ),
74
94
ResourceName : resourceName ,
75
95
ImportStateIdFunc : testAccCheckMongoDBAtlasSearchIndexImportStateIDFunc (resourceName ),
76
96
ImportState : true ,
@@ -247,6 +267,8 @@ func testAccCheckMongoDBAtlasSearchIndexImportStateIDFunc(resourceName string) r
247
267
return "" , fmt .Errorf ("not found: %s" , resourceName )
248
268
}
249
269
250
- return rs .Primary .ID , nil
270
+ ids := decodeStateID (rs .Primary .ID )
271
+
272
+ return fmt .Sprintf ("%s--%s--%s" , ids ["project_id" ], ids ["cluster_name" ], ids ["index_id" ]), nil
251
273
}
252
274
}
0 commit comments