@@ -1405,3 +1405,52 @@ func TestSchemaVarsValidation_SingleFile(t *testing.T) {
1405
1405
t .Fatalf ("expected %d diagnostics, %d given" , expectedCount , diagsCount )
1406
1406
}
1407
1407
}
1408
+
1409
+ func TestSchemaVarsValidation_outsideOfModule (t * testing.T ) {
1410
+ ctx := context .Background ()
1411
+ ss , err := state .NewStateStore ()
1412
+ if err != nil {
1413
+ t .Fatal (err )
1414
+ }
1415
+
1416
+ testData , err := filepath .Abs ("testdata" )
1417
+ if err != nil {
1418
+ t .Fatal (err )
1419
+ }
1420
+ modPath := filepath .Join (testData , "standalone-tfvars" )
1421
+
1422
+ err = ss .Modules .Add (modPath )
1423
+ if err != nil {
1424
+ t .Fatal (err )
1425
+ }
1426
+
1427
+ fs := filesystem .NewFilesystem (ss .DocumentStore )
1428
+ ctx = lsctx .WithDocumentContext (ctx , lsctx.Document {})
1429
+ err = ParseModuleConfiguration (ctx , fs , ss .Modules , modPath )
1430
+ if err != nil {
1431
+ t .Fatal (err )
1432
+ }
1433
+ err = LoadModuleMetadata (ctx , ss .Modules , modPath )
1434
+ if err != nil {
1435
+ t .Fatal (err )
1436
+ }
1437
+ err = ParseVariables (ctx , fs , ss .Modules , modPath )
1438
+ if err != nil {
1439
+ t .Fatal (err )
1440
+ }
1441
+ err = SchemaVariablesValidation (ctx , ss .Modules , ss .ProviderSchemas , modPath )
1442
+ if err != nil {
1443
+ t .Fatal (err )
1444
+ }
1445
+
1446
+ mod , err := ss .Modules .ModuleByPath (modPath )
1447
+ if err != nil {
1448
+ t .Fatal (err )
1449
+ }
1450
+
1451
+ expectedCount := 0
1452
+ diagsCount := mod .VarsDiagnostics [ast .SchemaValidationSource ].Count ()
1453
+ if diagsCount != expectedCount {
1454
+ t .Fatalf ("expected %d diagnostics, %d given" , expectedCount , diagsCount )
1455
+ }
1456
+ }
0 commit comments