@@ -24,8 +24,8 @@ func TestMappedItemDiffsFromPlan(t *testing.T) {
2424 t .Error (err )
2525 }
2626
27- if len (mappedItemDiffs ) != 3 {
28- t .Errorf ("Expected 3 changes, got %v:" , len (mappedItemDiffs ))
27+ if len (mappedItemDiffs ) != 4 {
28+ t .Errorf ("Expected 4 changes, got %v:" , len (mappedItemDiffs ))
2929 for _ , diff := range mappedItemDiffs {
3030 t .Errorf (" %v" , diff )
3131 }
@@ -34,6 +34,7 @@ func TestMappedItemDiffsFromPlan(t *testing.T) {
3434 var nats_box_deployment * sdp.MappedItemDiff
3535 var api_server_deployment * sdp.MappedItemDiff
3636 var aws_iam_policy * sdp.MappedItemDiff
37+ var secret * sdp.MappedItemDiff
3738
3839 for _ , diff := range mappedItemDiffs {
3940 item := diff .GetItem ().GetBefore ()
@@ -52,6 +53,8 @@ func TestMappedItemDiffsFromPlan(t *testing.T) {
5253 api_server_deployment = diff
5354 } else if item .GetType () == "iam-policy" {
5455 aws_iam_policy = diff
56+ } else if item .GetType () == "Secret" {
57+ secret = diff
5558 }
5659 }
5760
@@ -144,6 +147,15 @@ func TestMappedItemDiffsFromPlan(t *testing.T) {
144147 if aws_iam_policy .GetMappingQuery ().GetQuery () != "arn:aws:iam::123456789012:policy/test-alb-ingress" {
145148 t .Errorf ("Expected aws_iam_policy query query to be 'arn:aws:iam::123456789012:policy/test-alb-ingress', got '%v'" , aws_iam_policy .GetMappingQuery ().GetQuery ())
146149 }
150+
151+ // check secret
152+ t .Logf ("secret: %v" , secret )
153+ if secret == nil {
154+ t .Fatalf ("Expected secret to be set, but it's not" )
155+ }
156+ if secret .GetMappingQuery ().GetScope () != "dogfood.default" {
157+ t .Errorf ("Expected secret query scope to be 'dogfood.default', got '%v'" , secret .GetMappingQuery ().GetScope ())
158+ }
147159}
148160
149161// note that these tests need to allocate the input map for every test to avoid
@@ -249,3 +261,28 @@ func TestMaskSensitiveData(t *testing.T) {
249261
250262 })
251263}
264+
265+ func TestExtractProviderNameFromConfigKey (t * testing.T ) {
266+ tests := []struct {
267+ ConfigKey string
268+ Expected string
269+ }{
270+ {
271+ ConfigKey : "kubernetes" ,
272+ Expected : "kubernetes" ,
273+ },
274+ {
275+ ConfigKey : "module.core:kubernetes" ,
276+ Expected : "kubernetes" ,
277+ },
278+ }
279+
280+ for _ , test := range tests {
281+ t .Run (test .ConfigKey , func (t * testing.T ) {
282+ actual := extractProviderNameFromConfigKey (test .ConfigKey )
283+ if actual != test .Expected {
284+ t .Errorf ("Expected %v, got %v" , test .Expected , actual )
285+ }
286+ })
287+ }
288+ }
0 commit comments