Skip to content

Commit

Permalink
Add children index
Browse files Browse the repository at this point in the history
  • Loading branch information
devlead committed Oct 14, 2023
1 parent 744cbc4 commit 73048d4
Show file tree
Hide file tree
Showing 24 changed files with 318 additions and 71 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -350,4 +350,6 @@ MigrationBackup/

[Aa]rtifacts/

launchSettings.json
launchSettings.json

!src/**/ARM/*.cs
5 changes: 3 additions & 2 deletions build.cake
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,8 @@ Task("Clean")
.Append("ARI")
.Append("inventory")
.AppendQuotedSecret(data.AzureTenantId)
.AppendQuoted(data.IntegrationTestPath.FullPath),
.AppendQuoted(data.IntegrationTestPath.FullPath)
.Append("--skip-tenant-overview"),
WorkingDirectory = data.IntegrationTestPath
}
)
Expand All @@ -190,7 +191,7 @@ Task("Clean")
.WithCriteria<BuildData>((context, data) => data.ShouldRunIntegrationTests(), "ShouldRunIntegrationTests")
.Does<BuildData>(
async (context, data) => {
var resultPath = data.IntegrationTestPath.Combine(data.AzureDomain);
var resultPath = data.IntegrationTestPath;
await GitHubActions.Commands.UploadArtifact(
resultPath,
data.AzureDomain
Expand Down
2 changes: 1 addition & 1 deletion src/ARI.TestWeb/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
.CreateDefault(args)
.AddThemeFromUri(new Uri("https://github.com/statiqdev/CleanBlog/archive/8543531ff5acfb9db97b88ec7121c693f198f942.zip"))
.AddWeb()
.AddSetting(new KeyValuePair<string, object>(Keys.LinkRoot, "/bri"))
.AddSetting(new KeyValuePair<string, object>(Keys.LinkRoot, "/ari"))
.AddSetting(new KeyValuePair<string, object> (WebKeys.ApplyDirectoryMetadata , true))
.AddSetting(new KeyValuePair<string, object>(MarkdownKeys.MarkdownExtensions, new[]
{
Expand Down
56 changes: 56 additions & 0 deletions src/ARI.Tests/Fixture/MocksFixture.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
using ARI.Models.Tenant;
using ARI.Models.Tenant.Subscription;
using ARI.Models.Tenant.Subscription.ResourceGroup;

namespace ARI.Tests.Fixture;
public static class MocksFixture
{
public static AzureTenant AzureTenant { get; } = new (
"Id",
"TenantId",
"CountryCode",
"DisplayName",
new[] { "Domain1", "Domain2" },
"TenantCategory",
"DefaultDomain",
"TenantType",
"TenantBrandingLogoUrl"
);
public static Subscription Subscription { get; } = new(
"Id",
"SubscriptionId",
"TenantId",
"DisplayName",
"State",
new SubscriptionPolicies(
"LocationPlacementId",
"QuotaId",
"SpendingLimit"
),
"AuthorizationSource",
Array.Empty<ManagedByTenant>()
);
public static IDictionary<string, string> Tags { get; } = new Dictionary<string, string>
{
{ "Tag1", "Value1" },
{ "Tag2", "Value2" }
}.AsReadOnly();

public static ResourceGroup ResourceGroup { get; } = new(
"Id",
"Location",
"ManagedBy",
"Name",
new Dictionary<string, string>
{
{ "provisioningState", "Succeeded" }
},
"Type"
);
public static ICollection<AzureResourceBase> Children { get; } = new AzureResourceBase[]
{
AzureTenant,
Subscription,
ResourceGroup,
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
Path: /home/docs/rdvmohoro.mail.ccsctp.net/291bba3f-e0a5-47bc-a099-3bdcb2a50a05/index.md,
Exists: true,
Hidden: false,
Length: 1523
Length: 2525
}
]
},
Expand Down Expand Up @@ -87,7 +87,7 @@
Path: /home/docs/rdvmohoro.mail.ccsctp.net/72ac930a-f34e-42d8-b06d-dc2a9e12ed71/index.md,
Exists: true,
Hidden: false,
Length: 1524
Length: 2132
}
]
}
Expand All @@ -97,7 +97,7 @@
Path: /home/docs/rdvmohoro.mail.ccsctp.net/index.md,
Exists: true,
Hidden: false,
Length: 1229
Length: 2033
}
]
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
{
Output: {
Path: /home/docs,
Exists: true,
Hidden: false,
Directories: [
{
Path: /home/docs/291bba3f-e0a5-47bc-a099-3bdcb2a50a05,
Exists: true,
Hidden: false,
Directories: [
{
Path: /home/docs/291bba3f-e0a5-47bc-a099-3bdcb2a50a05/lab-dev,
Exists: true,
Hidden: false,
Files: [
{
Path: /home/docs/291bba3f-e0a5-47bc-a099-3bdcb2a50a05/lab-dev/index.md,
Exists: true,
Hidden: false,
Length: 1643
}
]
},
{
Path: /home/docs/291bba3f-e0a5-47bc-a099-3bdcb2a50a05/lab-prd,
Exists: true,
Hidden: false,
Files: [
{
Path: /home/docs/291bba3f-e0a5-47bc-a099-3bdcb2a50a05/lab-prd/index.md,
Exists: true,
Hidden: false,
Length: 1643
}
]
},
{
Path: /home/docs/291bba3f-e0a5-47bc-a099-3bdcb2a50a05/lab-stg,
Exists: true,
Hidden: false,
Files: [
{
Path: /home/docs/291bba3f-e0a5-47bc-a099-3bdcb2a50a05/lab-stg/index.md,
Exists: true,
Hidden: false,
Length: 1643
}
]
}
],
Files: [
{
Path: /home/docs/291bba3f-e0a5-47bc-a099-3bdcb2a50a05/index.md,
Exists: true,
Hidden: false,
Length: 2525
}
]
},
{
Path: /home/docs/72ac930a-f34e-42d8-b06d-dc2a9e12ed71,
Exists: true,
Hidden: false,
Directories: [
{
Path: /home/docs/72ac930a-f34e-42d8-b06d-dc2a9e12ed71/common-dev,
Exists: true,
Hidden: false,
Files: [
{
Path: /home/docs/72ac930a-f34e-42d8-b06d-dc2a9e12ed71/common-dev/index.md,
Exists: true,
Hidden: false,
Length: 1646
}
]
}
],
Files: [
{
Path: /home/docs/72ac930a-f34e-42d8-b06d-dc2a9e12ed71/index.md,
Exists: true,
Hidden: false,
Length: 2132
}
]
}
],
Files: [
{
Path: /home/docs/index.md,
Exists: true,
Hidden: false,
Length: 883
}
]
}
}
8 changes: 5 additions & 3 deletions src/ARI.Tests/Unit/Commands/InventoryCommandTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ namespace ARI.Tests.Unit.Commands;
[TestFixture]
public class InventoryCommandTests
{
[Test]
public async Task ExecuteAsync()
[TestCase(false)]
[TestCase(true)]
public async Task ExecuteAsync(bool skipTenantOverview)
{
// Given
var context = new CommandContext(
Expand All @@ -20,7 +21,8 @@ public async Task ExecuteAsync()
var settings = new InventorySettings
{
TenantId = Constants.Tenant.Id,
OutputPath = "/home/docs"
OutputPath = "/home/docs",
SkipTenantOverview = skipTenantOverview
};
var (
cakeContext,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[Description](Href)
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[Description](Description)
11 changes: 11 additions & 0 deletions src/ARI.Tests/Unit/Extensions/StringMarkdownExtensionsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,15 @@ public async Task Bold(string value)
// Then
await Verify(result);
}

[TestCase("Description", null)]
[TestCase("Description", "Href")]
public async Task Link(string description, string? href)
{
// Given / When
var result = description.Link(href);

// Then
await Verify(result);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@

## Children

| | |
|-------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------|
| [DefaultDomain](DefaultDomain) | [DisplayName](DefaultDomain) |
| [SubscriptionId](SubscriptionId) | [DisplayName](SubscriptionId) |
| [Name](Name) | [Location](Name) |
61 changes: 20 additions & 41 deletions src/ARI.Tests/Unit/Extensions/TextWriterMarkdownExtensionsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,7 @@ public async Task AddTenantOverview()
{
// Given
var sw = new StringWriter();
var tenant = new AzureTenant(
"Id",
"TenantId",
"CountryCode",
"DisplayName",
new[] { "Domain1", "Domain2" },
"TenantCategory",
"DefaultDomain",
"TenantType",
"TenantBrandingLogoUrl"
);
var tenant = MocksFixture.AzureTenant;

// When
await sw.AddTenantOverview(
Expand All @@ -58,20 +48,7 @@ public async Task AddSubscriptionOverview()
{
// Given
var sw = new StringWriter();
var subscription = new Subscription(
"Id",
"SubscriptionId",
"TenantId",
"DisplayName",
"State",
new SubscriptionPolicies(
"LocationPlacementId",
"QuotaId",
"SpendingLimit"
),
"AuthorizationSource",
Array.Empty<ManagedByTenant>()
);
var subscription = MocksFixture.Subscription;

// When
await sw.AddSubscriptionOverview(
Expand All @@ -87,11 +64,7 @@ public async Task AddTags()
{
// Given
var sw = new StringWriter();
var tags = new Dictionary<string, string>
{
{ "Tag1", "Value1" },
{ "Tag2", "Value2" }
};
var tags = MocksFixture.Tags;

// When
await sw.AddTags(tags);
Expand All @@ -105,17 +78,7 @@ public async Task AddResourceGroupOverview()
{
// Given
var sw = new StringWriter();
var resourceGroup = new ResourceGroup(
"Id",
"Location",
"ManagedBy",
"Name",
new Dictionary<string, string>
{
{ "provisioningState", "Succeeded" }
},
"Type"
);
var resourceGroup = MocksFixture.ResourceGroup;

// When
await sw.AddResourceGroupOverview(
Expand All @@ -125,4 +88,20 @@ await sw.AddResourceGroupOverview(
// Then
await Verify(sw);
}

[Test]
public async Task AddChildrenIndex()
{
// Given
var sw = new StringWriter();
var children = MocksFixture.Children;

// When
await sw.AddChildrenIndex(
children
);

// Then
await Verify(sw);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
TenantId: Guid_3
}
],
PublicId: Guid_1,
Description: Example Subscription,
Order: 1,
Tags: {
Expand Down Expand Up @@ -43,6 +44,7 @@
TenantId: Guid_5
}
],
PublicId: Guid_4,
Description: Example Subscription2,
Order: 2,
Tags: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,7 @@
rdvmohoro.com
],
DefaultDomain: rdvmohoro.mail.ccsctp.net,
TenantType: AAD
TenantType: AAD,
PublicId: rdvmohoro.mail.ccsctp.net,
Description: TEST_TEST_RDV
}
Loading

0 comments on commit 73048d4

Please sign in to comment.