@@ -18,13 +18,15 @@ func TestAccKongSni(t *testing.T) {
1818 Config : testCreateSniConfig ,
1919 Check : resource .ComposeTestCheckFunc (
2020 testAccCheckKongSniExists ("kong_sni.sni" ),
21+ //testAccCheckForChildIdCorrect("kong_certificate.certificate1", "kong_sni.sni", "certificate_id"),
2122 resource .TestCheckResourceAttr ("kong_sni.sni" , "name" , "www.example.com" ),
2223 ),
2324 },
2425 {
2526 Config : testUpdateSniConfig ,
2627 Check : resource .ComposeTestCheckFunc (
2728 testAccCheckKongSniExists ("kong_sni.sni" ),
29+ //testAccCheckForChildIdCorrect("kong_certificate.certificate2", "kong_sni.sni", "certificate_id"),
2830 resource .TestCheckResourceAttr ("kong_sni.sni" , "name" , "www.example.com" ),
2931 ),
3032 },
@@ -36,20 +38,20 @@ func testAccCheckKongSniDestroy(state *terraform.State) error {
3638
3739 client := testAccProvider .Meta ().(* gokong.KongAdminClient )
3840
39- for _ , rs := range state .RootModule ().Resources {
40- if rs .Type != "kong_sni" {
41- continue
42- }
41+ snis := getResourcesByType ("kong_sni" , state )
4342
44- response , err := client .Snis ().GetByName (rs .Primary .ID )
43+ if len (snis ) != 1 {
44+ return fmt .Errorf ("expecting only 1 sni resource found %v" , len (snis ))
45+ }
4546
46- if err != nil {
47- return fmt .Errorf ("error calling get sni by id: %v" , err )
48- }
47+ response , err := client .Snis ().GetByName (snis [0 ].Primary .ID )
4948
50- if response != nil {
51- return fmt .Errorf ("sni %s still exists, %+v" , rs .Primary .ID , response )
52- }
49+ if err != nil {
50+ return fmt .Errorf ("error calling get sni by id: %v" , err )
51+ }
52+
53+ if response != nil {
54+ return fmt .Errorf ("sni %s still exists, %+v" , snis [0 ].Primary .ID , response )
5355 }
5456
5557 return nil
0 commit comments