Skip to content

Commit

Permalink
Add cloud and module alias configurations (#4576)
Browse files Browse the repository at this point in the history
* Add cloud and module alias configurations

* Address feedback

* Fix an error message

* Fix test failures

* Remove AzureGermanCloud

* Remove AzureGermanCloud from tests

* Address feedback

* Remove Dogfood from cloud profiles

* Add note for removing IsInternalInit later
  • Loading branch information
shenglol authored Sep 29, 2021
1 parent 1e9e336 commit 9e3d155
Show file tree
Hide file tree
Showing 95 changed files with 1,950 additions and 1,222 deletions.
24 changes: 8 additions & 16 deletions src/Bicep.Cli.IntegrationTests/BuildCommandTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -286,29 +286,25 @@ public async Task Build_LockedOutputFile_ShouldProduceExpectedError()
}

[TestMethod]
public async Task Build_WithEmptyBicepConfig_ShouldProduceOutputFile()
public async Task Build_WithEmptyBicepConfig_ShouldProduceConfigurationError()
{
string testOutputPath = Path.Combine(TestContext.ResultsDirectory, Guid.NewGuid().ToString());
var inputFile = FileHelper.SaveResultFile(this.TestContext, "main.bicep", DataSets.Empty.Bicep, testOutputPath);
FileHelper.SaveResultFile(this.TestContext, "bicepconfig.json", string.Empty, testOutputPath);
var configurationPath = FileHelper.SaveResultFile(this.TestContext, "bicepconfig.json", string.Empty, testOutputPath);

var (output, error, result) = await Bicep("build", inputFile);

result.Should().Be(0);
result.Should().Be(1);
output.Should().BeEmpty();
error.Should().BeEmpty();

var expectedOutputFile = Path.Combine(testOutputPath, "main.json");

File.Exists(expectedOutputFile).Should().BeTrue();
error.Should().StartWith($"Failed to parse the contents of the Bicep configuration file \"{configurationPath}\" as valid JSON: \"The input does not contain any JSON tokens. Expected the input to start with a valid JSON token, when isFinalBlock is true. LineNumber: 0 | BytePositionInLine: 0.\".");
}

[TestMethod]
public async Task Build_WithInvalidBicepConfig_ShouldProduceOutputFile()
public async Task Build_WithInvalidBicepConfig_ShouldProduceConfigurationError()
{
string testOutputPath = Path.Combine(TestContext.ResultsDirectory, Guid.NewGuid().ToString());
var inputFile = FileHelper.SaveResultFile(this.TestContext, "main.bicep", DataSets.Empty.Bicep, testOutputPath);
FileHelper.SaveResultFile(this.TestContext, "bicepconfig.json", @"{
var configurationPath = FileHelper.SaveResultFile(this.TestContext, "bicepconfig.json", @"{
""analyzers"": {
""core"": {
""verbose"": false,
Expand All @@ -320,13 +316,9 @@ public async Task Build_WithInvalidBicepConfig_ShouldProduceOutputFile()

var (output, error, result) = await Bicep("build", inputFile);

result.Should().Be(0);
result.Should().Be(1);
output.Should().BeEmpty();
error.Should().BeEmpty();

var expectedOutputFile = Path.Combine(testOutputPath, "main.json");

File.Exists(expectedOutputFile).Should().BeTrue();
error.Should().StartWith($"Failed to parse the contents of the Bicep configuration file \"{configurationPath}\" as valid JSON: \"Expected depth to be zero at the end of the JSON payload. There is an open JSON object or array that should be closed. LineNumber: 8 | BytePositionInLine: 0.\".");
}

[TestMethod]
Expand Down
2 changes: 1 addition & 1 deletion src/Bicep.Cli.IntegrationTests/TestBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ protected static IEnumerable<string> GetAllDiagnostics(string bicepFilePath, ICo
{
var dispatcher = new ModuleDispatcher(new DefaultModuleRegistryProvider(BicepTestConstants.FileResolver, clientFactory, templateSpecRepositoryFactory, BicepTestConstants.Features));
var sourceFileGrouping = SourceFileGroupingBuilder.Build(BicepTestConstants.FileResolver, dispatcher, new Workspace(), PathHelper.FilePathToFileUrl(bicepFilePath));
var compilation = new Compilation(TestTypeHelper.CreateEmptyProvider(), sourceFileGrouping, null);
var compilation = new Compilation(TestTypeHelper.CreateEmptyProvider(), sourceFileGrouping, BicepTestConstants.BuiltInConfiguration);

var output = new List<string>();
foreach (var (bicepFile, diagnostics) in compilation.GetAllDiagnosticsByBicepFile())
Expand Down
20 changes: 19 additions & 1 deletion src/Bicep.Cli.IntegrationTests/packages.lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -1380,6 +1380,22 @@
"System.Threading.Tasks": "4.3.0"
}
},
"System.IO.Abstractions": {
"type": "Transitive",
"resolved": "13.2.47",
"contentHash": "t1hPTax+QnZscqwCY2Xuszm+qGm9qPDFvDPOjB31nR1XBtKDbt/RE5s0gBTOvQ9EP//jfrg2HEQUQyN5asFocg==",
"dependencies": {
"System.IO.FileSystem.AccessControl": "5.0.0"
}
},
"System.IO.Abstractions.TestingHelpers": {
"type": "Transitive",
"resolved": "13.2.47",
"contentHash": "pi6rVI4B0aB/QtpJuYXmcSQEGLOGK58mgsOWnf94syBQgNZ2KjJTduStR7RfKWY5EK9u42SJRi/mVRiyAEjqiw==",
"dependencies": {
"System.IO.Abstractions": "13.2.47"
}
},
"System.IO.Compression": {
"type": "Transitive",
"resolved": "4.3.0",
Expand Down Expand Up @@ -2261,7 +2277,8 @@
"Microsoft.Extensions.Configuration.Binder": "5.0.0",
"Microsoft.Extensions.Configuration.Json": "5.0.0",
"Newtonsoft.Json": "13.0.1",
"System.Collections.Immutable": "5.0.0"
"System.Collections.Immutable": "5.0.0",
"System.IO.Abstractions": "13.2.47"
}
},
"bicep.core.registryclient": {
Expand Down Expand Up @@ -2296,6 +2313,7 @@
"Microsoft.PowerShell.SDK": "7.1.3",
"Moq": "4.16.1",
"Newtonsoft.Json": "13.0.1",
"System.IO.Abstractions.TestingHelpers": "13.2.47",
"System.Management.Automation": "7.1.3"
}
},
Expand Down
Loading

0 comments on commit 9e3d155

Please sign in to comment.