Fixes + stable gateway ids
This commit is contained in:
29
api/payments/storage/model/gateway_affinity_identity_test.go
Normal file
29
api/payments/storage/model/gateway_affinity_identity_test.go
Normal 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")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user