using EntKube.Clusters.Domain; using EntKube.Clusters.Features.AdoptCluster.Components.Traefik; using FluentAssertions; namespace EntKube.Clusters.Tests.Features; /// /// Tests for the Traefik installer's Helm values generation. Verifies that /// the correct cloud-provider annotations are applied when internal LB mode /// is enabled, and that no annotations leak through when disabled. /// public class TraefikInstallerTests { [Fact] public void GetTraefikValues_InternalLbWithCleura_IncludesOpenStackAnnotation() { // When Traefik is configured as an internal LB on Cleura, it should use // the OpenStack annotation instead of dumping all provider annotations. Dictionary parameters = new() { ["internalLoadBalancer"] = "true" }; string values = TraefikInstaller.GetTraefikValues(parameters, CloudProvider.Cleura); values.Should().Contain("openstack-internal-load-balancer"); values.Should().NotContain("azure-load-balancer-internal"); } [Fact] public void GetTraefikValues_InternalLbWithAzure_IncludesAzureAnnotation() { Dictionary parameters = new() { ["internalLoadBalancer"] = "true" }; string values = TraefikInstaller.GetTraefikValues(parameters, CloudProvider.Azure); values.Should().Contain("azure-load-balancer-internal"); values.Should().NotContain("openstack-internal-load-balancer"); } [Fact] public void GetTraefikValues_NoInternalLb_HasNoAnnotations() { // When internalLoadBalancer is not set, no annotations should be emitted // regardless of the cloud provider. Dictionary parameters = new(); string values = TraefikInstaller.GetTraefikValues(parameters, CloudProvider.Cleura); values.Should().NotContain("annotations:"); } [Fact] public void GetTraefikValues_CustomReplicas_IncludesReplicaCount() { // When a custom replica count is specified, the generated values // should reflect that in the deployment section. Dictionary parameters = new() { ["replicas"] = "5" }; string values = TraefikInstaller.GetTraefikValues(parameters, CloudProvider.None); values.Should().Contain("replicas: 5"); } [Fact] public void GetTraefikValues_DashboardEnabled_IncludesDashboardConfig() { // When the dashboard is enabled, the generated values should include // dashboard configuration. Dictionary parameters = new() { ["dashboardEnabled"] = "true" }; string values = TraefikInstaller.GetTraefikValues(parameters, CloudProvider.None); values.Should().Contain("dashboard"); } }