32 lines
961 B
Go
32 lines
961 B
Go
package webui
|
|
|
|
import (
|
|
"context"
|
|
"testing"
|
|
|
|
"github.com/samcharles93/archie-core/internal/domain/identity"
|
|
)
|
|
|
|
type namedActors struct{ identity.Repository }
|
|
|
|
func (namedActors) Get(_ context.Context, id identity.IdentityID) (identity.Identity, error) {
|
|
if id == "11111111-1111-4111-8111-111111111111" || id == "d898c8c8-47f4-5d6c-945a-2e7dc98ca1c1" {
|
|
return identity.Identity{ID: id, DisplayName: "Sam"}, nil
|
|
}
|
|
return identity.Identity{}, identity.ErrNotFound
|
|
}
|
|
|
|
func TestAuditActorNames(t *testing.T) {
|
|
name := (&Server{Identities: namedActors{}}).actorNames(t.Context())
|
|
for _, tc := range []struct{ id, want string }{
|
|
{"11111111-1111-4111-8111-111111111111", "Sam"},
|
|
{"d898c8c8-47f4-5d6c-945a-2e7dc98ca1c1", "Sam"},
|
|
{"22222222-2222-4222-8222-222222222222", "Unavailable identity"},
|
|
{"system:migration", "system:migration"},
|
|
} {
|
|
if got := name(tc.id); got != tc.want {
|
|
t.Errorf("actor %s = %s, want %s", tc.id, got, tc.want)
|
|
}
|
|
}
|
|
}
|