Fixes + stable gateway ids

This commit is contained in:
Stephan D
2026-02-18 20:38:08 +01:00
parent 4dc182bfa2
commit 770c7b9da9
119 changed files with 3000 additions and 734 deletions

View File

@@ -0,0 +1,29 @@
package model
import "testing"
func TestGatewayIdentityKey(t *testing.T) {
if got, want := GatewayIdentityKey(" gw ", "inst-1", "grpc://one"), "gw|inst-1"; got != want {
t.Fatalf("unexpected gateway identity key: got=%q want=%q", got, want)
}
if got, want := GatewayIdentityKey("gw", "", " grpc://one "), "gw|grpc://one"; got != want {
t.Fatalf("unexpected gateway identity key with invoke fallback: got=%q want=%q", got, want)
}
if got, want := GatewayIdentityKey(" gw ", "", ""), "gw"; got != want {
t.Fatalf("unexpected gateway identity key with id only: got=%q want=%q", got, want)
}
if got := GatewayIdentityKey("", "inst-1", "grpc://one"); got != "" {
t.Fatalf("expected empty key when gateway id missing, got=%q", got)
}
}
func TestLessGatewayDescriptor(t *testing.T) {
a := &GatewayInstanceDescriptor{ID: "gw", InstanceID: "inst-a", InvokeURI: "grpc://a"}
b := &GatewayInstanceDescriptor{ID: "gw", InstanceID: "inst-b", InvokeURI: "grpc://b"}
if !LessGatewayDescriptor(a, b) {
t.Fatalf("expected inst-a to sort before inst-b")
}
if LessGatewayDescriptor(b, a) {
t.Fatalf("expected inst-b not to sort before inst-a")
}
}