Skip to content

Commit

Permalink
Prepare release
Browse files Browse the repository at this point in the history
  • Loading branch information
Vincent Wilms committed Sep 27, 2024
1 parent 89b589d commit 5ad0a52
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## v2.0.0-beta.25 - 2024-09-27

- Fix nested catalogs not being loaded properly.

## v2.0.0-beta.24 - 2024-03-15

- Follow Nexus changes.
Expand Down
3 changes: 3 additions & 0 deletions src/Nexus.Sources.Federation/Federation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@ public async Task<CatalogRegistration[]> GetCatalogRegistrationsAsync(string pat
if (path == "/")
path = _mountPoint;

else
path = path.TrimEnd('/');

var catalogInfos = await _nexusClient.Catalogs.GetChildCatalogInfosAsync(ToSourcePathPrefixedCatalogId(path), cancellationToken);

return catalogInfos
Expand Down
52 changes: 52 additions & 0 deletions tests/Nexus.Sources.Federation.Tests/FederationTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ public async Task ProvidesCatalogRegistrations(string? sourcePath, string? mount
.ReturnsAsync((string catalogId, CancellationToken cancellationToken) =>
{
Assert.True(catalogId.StartsWith('/'));
Assert.True(catalogId == "/" || !catalogId.EndsWith('/'));

var childCatalogId = catalogId == "/"
? catalogId + "TEST_CATALOG"
Expand Down Expand Up @@ -72,4 +73,55 @@ public async Task ProvidesCatalogRegistrations(string? sourcePath, string? mount
// assert
Assert.Equal(expectedCatalogId, catalogRegistrations.First().Path);
}

[Fact]
public async Task ProvidesNestedCatalogRegistrations()
{
var expectedCatalogId = "/mnt/name";
var searchPath = "/mnt/"; /* with trailing slash because Nexus does the same! */

// arrange
var catalogsClient = Mock.Of<ICatalogsClient>();

Mock.Get(catalogsClient)
.Setup(catalog => catalog.GetChildCatalogInfosAsync(
It.IsAny<string>(),
It.IsAny<CancellationToken>()
))
.ReturnsAsync((string catalogId, CancellationToken cancellationToken) =>
{
Assert.True(catalogId.StartsWith('/'));
Assert.True(!catalogId.EndsWith('/'));

var childCatalogId = expectedCatalogId;
var catalog = new CatalogInfo(childCatalogId, default, default, default, default, default, default, default, default, default, default, default!, default, default);

return new List<CatalogInfo>() { catalog };
});

var nexusClient = Mock.Of<INexusClient>();

Mock.Get(nexusClient)
.SetupGet(client => client.Catalogs)
.Returns(catalogsClient);

var dataSource = new Federation() { CreateNexusClient = _ => nexusClient } as IDataSource;

var context = new DataSourceContext(
ResourceLocator: new Uri("https://example.com"),
SystemConfiguration: default!,
SourceConfiguration: new Dictionary<string, JsonElement>()
{
["access-token"] = JsonSerializer.SerializeToElement("")
},
RequestConfiguration: default!);

await dataSource.SetContextAsync(context, NullLogger.Instance, CancellationToken.None);

// act
var catalogRegistrations = await dataSource.GetCatalogRegistrationsAsync(searchPath, CancellationToken.None);

// assert
Assert.Equal(expectedCatalogId, catalogRegistrations.First().Path);
}
}
2 changes: 1 addition & 1 deletion version.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"version": "2.0.0",
"suffix": "beta.24"
"suffix": "beta.25"
}

0 comments on commit 5ad0a52

Please sign in to comment.