-
Notifications
You must be signed in to change notification settings - Fork 760
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add broken test for provider registry end-to-end logic (#12748)
###### Microsoft Reviewers: [Open in CodeFlow](https://microsoft.github.io/open-pr/?codeflow=https://github.com/Azure/bicep/pull/12748)
- Loading branch information
1 parent
4d54e27
commit 460934a
Showing
4 changed files
with
81 additions
and
0 deletions.
There are no files selected for viewing
1 change: 1 addition & 0 deletions
1
src/Bicep.Core.IntegrationTests/Files/RegistryProviderTests/HttpProvider/types/index.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"Resources":{"request@v1":{"RelativePath":"v1/types.json","Index":12}},"Functions":{}} |
1 change: 1 addition & 0 deletions
1
src/Bicep.Core.IntegrationTests/Files/RegistryProviderTests/HttpProvider/types/v1/types.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
[{"1":{"Kind":1}},{"1":{"Kind":2}},{"1":{"Kind":3}},{"1":{"Kind":4}},{"1":{"Kind":5}},{"1":{"Kind":6}},{"1":{"Kind":7}},{"1":{"Kind":8}},{"6":{"Value":"raw"}},{"6":{"Value":"json"}},{"5":{"Elements":[8,9]}},{"2":{"Name":"request@v1","Properties":{"uri":{"Type":4,"Flags":1,"Description":"The HTTP request URI to submit a GET request to."},"format":{"Type":10,"Flags":0,"Description":"How to deserialize the response body."},"method":{"Type":4,"Flags":0,"Description":"The HTTP method to submit request to the given URI."},"statusCode":{"Type":3,"Flags":2,"Description":"The status code of the HTTP request."},"body":{"Type":0,"Flags":2,"Description":"The parsed request bodyz."}}}},{"4":{"Name":"request@v1","ScopeType":0,"Body":11,"Flags":0}}] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT License. | ||
|
||
using System; | ||
using System.IO; | ||
using System.Threading.Tasks; | ||
using System.Web.Services.Description; | ||
using Bicep.Core.Registry; | ||
using Bicep.Core.Samples; | ||
using Bicep.Core.UnitTests; | ||
using Bicep.Core.UnitTests.Assertions; | ||
using Bicep.Core.UnitTests.Utils; | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
using IOFileSystem = System.IO.Abstractions.FileSystem; | ||
|
||
namespace Bicep.Core.IntegrationTests; | ||
|
||
[TestClass] | ||
public class RegistryProviderTests : TestBase | ||
{ | ||
private static ServiceBuilder GetServiceBuilder(IContainerRegistryClientFactory clientFactory) | ||
=> new ServiceBuilder() | ||
.WithFeatureOverrides(new(ExtensibilityEnabled: true)) | ||
.WithContainerRegistryClientFactory(clientFactory); | ||
|
||
[TestMethod] | ||
[Ignore("In true TDD fashion, the functionality to fix this test is yet to be implemented")] | ||
public async Task Providers_published_to_a_registry_can_be_compiled() | ||
{ | ||
var registry = "example.azurecr.io"; | ||
var registryUri = new Uri($"https://{registry}"); | ||
var repository = $"test/provider/http"; | ||
|
||
// types taken from https://github.com/Azure/bicep-registry-providers/tree/21aadf24cd6e8c9c5da2db0d1438df9def548b09/providers/http | ||
var outputDirectory = FileHelper.SaveEmbeddedResourcesWithPathPrefix( | ||
TestContext, | ||
typeof(RegistryProviderTests).Assembly, | ||
"Files/RegistryProviderTests/HttpProvider"); | ||
|
||
var indexJson = Path.Combine(outputDirectory, "types/index.json"); | ||
|
||
var (clientFactory, _) = DataSetsExtensions.CreateMockRegistryClients(false, (registryUri, repository)); | ||
await DataSetsExtensions.PublishProviderToRegistryAsync(new IOFileSystem(), clientFactory, indexJson, $"br:{registry}/{repository}:1.2.3"); | ||
|
||
var result = CompilationHelper.Compile(GetServiceBuilder(clientFactory), """ | ||
provider 'br:example.azurecr.io/test/provider/[email protected]' | ||
resource dadJoke 'request@v1' = { | ||
uri: 'https://icanhazdadjoke.com' | ||
method: 'GET' | ||
format: 'json' | ||
} | ||
output joke string = dadJoke.body.joke | ||
"""); | ||
|
||
// TODO fix the below and assert that the template contents are correctly formatted | ||
result.Should().NotHaveAnyDiagnostics(); | ||
result.Template.Should().NotBeNull(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters