fix failing test

This commit is contained in:
Carlosokumu 2025-01-21 08:45:03 +03:00
parent fa355e3729
commit a63164bcf5
Signed by: carlos
GPG Key ID: 7BD6BC8160A5C953

View File

@ -9,6 +9,7 @@ import (
func TestApiRequestAlias(t *testing.T) { func TestApiRequestAlias(t *testing.T) {
ctx := context.Background() ctx := context.Background()
ctx = context.WithValue(ctx, "SessionId", "+25471234565")
storageService := mocks.NewMemStorageService(ctx) storageService := mocks.NewMemStorageService(ctx)
svc := NewDevAccountService(ctx, storageService) svc := NewDevAccountService(ctx, storageService)
ra, err := svc.CreateAccount(ctx) ra, err := svc.CreateAccount(ctx)
@ -16,10 +17,10 @@ func TestApiRequestAlias(t *testing.T) {
t.Fatal(err) t.Fatal(err)
} }
addr := ra.PublicKey addr := ra.PublicKey
_, err = svc.RequestAlias(ctx, addr, "+254f00") _, err = svc.RequestAlias(ctx, addr, "+254f00")
if err == nil { if err == nil {
t.Fatalf("expected error") t.Fatalf("expected error")
} }
alias := "+254712345678" alias := "+254712345678"
rb, err := svc.RequestAlias(ctx, addr, alias) rb, err := svc.RequestAlias(ctx, addr, alias)
@ -39,6 +40,7 @@ func TestApiRequestAlias(t *testing.T) {
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }
alias = "foo.sarafu.local"
if rb.Alias != alias { if rb.Alias != alias {
t.Fatalf("expected '%s', got '%s'", alias, rb.Alias) t.Fatalf("expected '%s', got '%s'", alias, rb.Alias)
} }
@ -56,12 +58,12 @@ func TestApiRequestAlias(t *testing.T) {
t.Fatal(err) t.Fatal(err)
} }
addr = ra.PublicKey addr = ra.PublicKey
alias = "foox"
rb, err = svc.RequestAlias(ctx, addr, alias) rb, err = svc.RequestAlias(ctx, addr, alias)
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }
alias = "foox" alias = "foox.sarafu.local"
if rb.Alias != alias { if rb.Alias != alias {
t.Fatalf("expected '%s', got '%s'", alias, rb.Alias) t.Fatalf("expected '%s', got '%s'", alias, rb.Alias)
} }