6
6
"path/filepath"
7
7
"runtime"
8
8
"sort"
9
+ "strings"
9
10
"testing"
10
11
11
12
protobuf "github.com/golang/protobuf/proto"
@@ -349,7 +350,7 @@ func TestConvertResources(t *testing.T) {
349
350
// and that no errors occur!
350
351
modules = append (modules , tfPlan .PlannedValues .RootModule )
351
352
}
352
- state , err := terraform .ConvertState (modules , string (tfPlanGraph ))
353
+ state , err := terraform .ConvertState (modules , string (tfPlanGraph ), richParameterResourceNames ( expected . parameters ) )
353
354
require .NoError (t , err )
354
355
sortResources (state .Resources )
355
356
sort .Strings (state .GitAuthProviders )
@@ -402,7 +403,7 @@ func TestConvertResources(t *testing.T) {
402
403
tfStateGraph , err := os .ReadFile (filepath .Join (dir , folderName + ".tfstate.dot" ))
403
404
require .NoError (t , err )
404
405
405
- state , err := terraform .ConvertState ([]* tfjson.StateModule {tfState .Values .RootModule }, string (tfStateGraph ))
406
+ state , err := terraform .ConvertState ([]* tfjson.StateModule {tfState .Values .RootModule }, string (tfStateGraph ), richParameterResourceNames ( expected . parameters ) )
406
407
require .NoError (t , err )
407
408
sortResources (state .Resources )
408
409
sort .Strings (state .GitAuthProviders )
@@ -461,7 +462,7 @@ func TestAppSlugValidation(t *testing.T) {
461
462
}
462
463
}
463
464
464
- state , err := terraform .ConvertState ([]* tfjson.StateModule {tfPlan .PlannedValues .RootModule }, string (tfPlanGraph ))
465
+ state , err := terraform .ConvertState ([]* tfjson.StateModule {tfPlan .PlannedValues .RootModule }, string (tfPlanGraph ), nil )
465
466
require .Nil (t , state )
466
467
require .Error (t , err )
467
468
require .ErrorContains (t , err , "invalid app slug" )
@@ -473,7 +474,7 @@ func TestAppSlugValidation(t *testing.T) {
473
474
}
474
475
}
475
476
476
- state , err = terraform .ConvertState ([]* tfjson.StateModule {tfPlan .PlannedValues .RootModule }, string (tfPlanGraph ))
477
+ state , err = terraform .ConvertState ([]* tfjson.StateModule {tfPlan .PlannedValues .RootModule }, string (tfPlanGraph ), nil )
477
478
require .Nil (t , state )
478
479
require .Error (t , err )
479
480
require .ErrorContains (t , err , "duplicate app slug" )
@@ -523,7 +524,7 @@ func TestInstanceTypeAssociation(t *testing.T) {
523
524
subgraph "root" {
524
525
"[root] ` + tc .ResourceType + `.dev" [label = "` + tc .ResourceType + `.dev", shape = "box"]
525
526
}
526
- }` )
527
+ }` , nil )
527
528
require .NoError (t , err )
528
529
require .Len (t , state .Resources , 1 )
529
530
require .Equal (t , state .Resources [0 ].GetInstanceType (), instanceType )
@@ -594,7 +595,7 @@ func TestInstanceIDAssociation(t *testing.T) {
594
595
"[root] ` + tc .ResourceType + `.dev" -> "[root] coder_agent.dev"
595
596
}
596
597
}
597
- ` )
598
+ ` , nil )
598
599
require .NoError (t , err )
599
600
require .Len (t , state .Resources , 1 )
600
601
require .Len (t , state .Resources [0 ].Agents , 1 )
@@ -623,3 +624,11 @@ func sortResources(resources []*proto.Resource) {
623
624
})
624
625
}
625
626
}
627
+
628
+ func richParameterResourceNames (parameters []* proto.RichParameter ) []string {
629
+ var names []string
630
+ for _ , p := range parameters {
631
+ names = append (names , strings .ToLower (p .Name ))
632
+ }
633
+ return names
634
+ }
0 commit comments