This commit is contained in:
Mateusz Gruszczyński committed 2026-10-22 19:20:57 +02:00
1 parent 58c7d63194
commit 5a0a063031
15 files changed
+124 -53

No files matched your search

+13 -1
View File
@@ -41,7 +41,7 @@ func TestServicesFromUsesStableComposeIdentity(t *testing.T) {
if len(got) != 1 {
t.Fatalf("got %d services", len(got))
}
if got[0].Key != "compose:lab/web/1:8080/tcp" || got[0].TechnicalName != "lab-web-8080" {
if got[0].Key != "compose:lab/web/1:8080/tcp" || got[0].TechnicalName != "web-1" {
t.Fatalf("unexpected service %#v", got[0])
}
if len(got[0].Bindings) != 1 || got[0].Bindings[0].PublicPort != 18080 {
@@ -64,6 +64,9 @@ func TestServicesFromKeepsComposeReplicasAndAllBindings(t *testing.T) {
if got[0].Key != "compose:lab/web/1:8080/tcp" || got[1].Key != "compose:lab/web/2:8080/tcp" {
t.Fatalf("unexpected replica keys %#v", got)
}
if got[0].TechnicalName != "lab-web-1" || got[1].TechnicalName != "lab-web-2" {
t.Fatalf("expected container-based hostnames, got %#v", got)
}
if len(got[0].Bindings) != 3 {
t.Fatalf("expected all published bindings, got %#v", got[0].Bindings)
}
@@ -243,3 +246,12 @@ func TestTLSInventoryReportsServingCertificateFingerprint(t *testing.T) {
t.Fatalf("inventory fingerprint = %q, want %q", got.CertificateSHA256, fingerprint)
}
}
func TestTechnicalNameIgnoresImageAndPort(t *testing.T) {
c := dockerContainer{Names: []string{"/My_App"}, Image: "registry.example.com/image:latest"}
one := servicesFrom([]dockerContainer{{Names: c.Names, Image: c.Image, Ports: []dockerPort{{PrivatePort: 80, PublicPort: 8080, Type: "tcp"}}}})
two := servicesFrom([]dockerContainer{{Names: c.Names, Image: "changed", Ports: []dockerPort{{PrivatePort: 8080, PublicPort: 9000, Type: "tcp"}}}})
if len(one) != 1 || len(two) != 1 || one[0].TechnicalName != "my-app" || two[0].TechnicalName != "my-app" {
t.Fatalf("technical names must use the container name: %#v %#v", one, two)
}
}