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"
@@ -366,7 +367,7 @@ func TestConvertResources(t *testing.T) {
366
367
// and that no errors occur!
367
368
modules = append (modules , tfPlan .PlannedValues .RootModule )
368
369
}
369
- state , err := terraform .ConvertState (modules , string (tfPlanGraph ))
370
+ state , err := terraform .ConvertState (modules , string (tfPlanGraph ), richParameterResourceNames ( expected . parameters ) )
370
371
require .NoError (t , err )
371
372
sortResources (state .Resources )
372
373
sort .Strings (state .GitAuthProviders )
@@ -419,7 +420,7 @@ func TestConvertResources(t *testing.T) {
419
420
tfStateGraph , err := os .ReadFile (filepath .Join (dir , folderName + ".tfstate.dot" ))
420
421
require .NoError (t , err )
421
422
422
- state , err := terraform .ConvertState ([]* tfjson.StateModule {tfState .Values .RootModule }, string (tfStateGraph ))
423
+ state , err := terraform .ConvertState ([]* tfjson.StateModule {tfState .Values .RootModule }, string (tfStateGraph ), richParameterResourceNames ( expected . parameters ) )
423
424
require .NoError (t , err )
424
425
sortResources (state .Resources )
425
426
sort .Strings (state .GitAuthProviders )
@@ -478,7 +479,7 @@ func TestAppSlugValidation(t *testing.T) {
478
479
}
479
480
}
480
481
481
- state , err := terraform .ConvertState ([]* tfjson.StateModule {tfPlan .PlannedValues .RootModule }, string (tfPlanGraph ))
482
+ state , err := terraform .ConvertState ([]* tfjson.StateModule {tfPlan .PlannedValues .RootModule }, string (tfPlanGraph ), nil )
482
483
require .Nil (t , state )
483
484
require .Error (t , err )
484
485
require .ErrorContains (t , err , "invalid app slug" )
@@ -490,7 +491,7 @@ func TestAppSlugValidation(t *testing.T) {
490
491
}
491
492
}
492
493
493
- state , err = terraform .ConvertState ([]* tfjson.StateModule {tfPlan .PlannedValues .RootModule }, string (tfPlanGraph ))
494
+ state , err = terraform .ConvertState ([]* tfjson.StateModule {tfPlan .PlannedValues .RootModule }, string (tfPlanGraph ), nil )
494
495
require .Nil (t , state )
495
496
require .Error (t , err )
496
497
require .ErrorContains (t , err , "duplicate app slug" )
@@ -540,7 +541,7 @@ func TestInstanceTypeAssociation(t *testing.T) {
540
541
subgraph "root" {
541
542
"[root] ` + tc .ResourceType + `.dev" [label = "` + tc .ResourceType + `.dev", shape = "box"]
542
543
}
543
- }` )
544
+ }` , nil )
544
545
require .NoError (t , err )
545
546
require .Len (t , state .Resources , 1 )
546
547
require .Equal (t , state .Resources [0 ].GetInstanceType (), instanceType )
@@ -611,7 +612,7 @@ func TestInstanceIDAssociation(t *testing.T) {
611
612
"[root] ` + tc .ResourceType + `.dev" -> "[root] coder_agent.dev"
612
613
}
613
614
}
614
- ` )
615
+ ` , nil )
615
616
require .NoError (t , err )
616
617
require .Len (t , state .Resources , 1 )
617
618
require .Len (t , state .Resources [0 ].Agents , 1 )
@@ -640,3 +641,11 @@ func sortResources(resources []*proto.Resource) {
640
641
})
641
642
}
642
643
}
644
+
645
+ func richParameterResourceNames (parameters []* proto.RichParameter ) []string {
646
+ var names []string
647
+ for _ , p := range parameters {
648
+ names = append (names , strings .ToLower (p .Name ))
649
+ }
650
+ return names
651
+ }
0 commit comments