@@ -398,6 +398,51 @@ func TestInferModuleSchemaFromGitHubSourceWithSubModule(t *testing.T) {
398
398
}
399
399
}
400
400
401
+ func TestInferModuleSchemaFromGitHubSourceWithSubModuleAndVersion (t * testing.T ) {
402
+ ctx := context .Background ()
403
+ packageName := packageName ("consulCluster" )
404
+ executors := getExecutorsFromEnv ()
405
+ for _ , executor := range executors {
406
+ t .Run ("executor=" + executor , func (t * testing.T ) {
407
+ tf := newTestRuntime (t , executor )
408
+ source := TFModuleSource ("github.com/hashicorp/terraform-aws-consul//modules/consul-cluster?ref=v0.11.0" )
409
+ referencedVersion , ok := source .ReferencedVersionInURL ()
410
+ assert .True (t , ok , "referenced version should be found in the source URL" )
411
+ assert .Equal (t , "0.11.0" , referencedVersion , "referenced version should be 0.11.0" )
412
+ consulClusterSchema , err := InferModuleSchema (ctx ,
413
+ tf ,
414
+ packageName ,
415
+ "github.com/hashicorp/terraform-aws-consul//modules/consul-cluster?ref=v0.11.0" ,
416
+ TFModuleVersion (referencedVersion ))
417
+
418
+ assert .NoError (t , err , "failed to infer module schema for github submodule" )
419
+ assert .NotNil (t , consulClusterSchema , "inferred module schema for aws consul cluster submodule is nil" )
420
+ // verify a sample of the inputs with different inferred types
421
+ expectedSampleInputs := map [string ]* schema.PropertySpec {
422
+ "ami_id" : {
423
+ Description : "The ID of the AMI to run in this cluster. " +
424
+ "Should be an AMI that had Consul installed and configured by the install-consul module." ,
425
+ Secret : false ,
426
+ TypeSpec : stringType ,
427
+ },
428
+ "spot_price" : {
429
+ Description : "The maximum hourly price to pay for EC2 Spot Instances." ,
430
+ Secret : false ,
431
+ TypeSpec : numberType ,
432
+ },
433
+ }
434
+
435
+ for name , expected := range expectedSampleInputs {
436
+ actual , ok := consulClusterSchema .Inputs [resource .PropertyKey (name )]
437
+ assert .True (t , ok , "input %s is missing from the schema" , name )
438
+ assert .Equal (t , expected .Description , actual .Description , "input %s description is incorrect" , name )
439
+ assert .Equal (t , expected .Secret , actual .Secret , "input %s secret is incorrect" , name )
440
+ assert .Equal (t , expected .TypeSpec , actual .TypeSpec , "input %s type is incorrect" , name )
441
+ }
442
+ })
443
+ }
444
+ }
445
+
401
446
func TestResolveModuleSources (t * testing.T ) {
402
447
executors := getExecutorsFromEnv ()
403
448
for _ , executor := range executors {
0 commit comments