(t *testing.T)
| 16 | ) |
| 17 | |
| 18 | func TestCreateAgent(t *testing.T) { |
| 19 | pool := testutil.TestDB(t) |
| 20 | store := identity.NewStore(pool) |
| 21 | ctx := context.Background() |
| 22 | |
| 23 | user, err := store.CreateOrGetUser(ctx, "owner@example.com", "Owner", "google-create-agent") |
| 24 | if err != nil { |
| 25 | t.Fatalf("CreateOrGetUser: %v", err) |
| 26 | } |
| 27 | |
| 28 | if _, err := store.ClaimOrCreateDomain(ctx, "bot.example.com", user.ID); err != nil { |
| 29 | t.Fatalf("ClaimOrCreateDomain: %v", err) |
| 30 | } |
| 31 | |
| 32 | a, err := store.CreateAgent(ctx, "agent@bot.example.com", "bot.example.com", "", "https://example.com/webhook", "", user.ID) |
| 33 | if err != nil { |
| 34 | t.Fatalf("CreateAgent: %v", err) |
| 35 | } |
| 36 | |
| 37 | if a.ID != "agent@bot.example.com" { |
| 38 | t.Errorf("ID = %q, want %q", a.ID, "agent@bot.example.com") |
| 39 | } |
| 40 | if a.Domain != "bot.example.com" { |
| 41 | t.Errorf("Domain = %q, want %q", a.Domain, "bot.example.com") |
| 42 | } |
| 43 | if a.DomainVerified { |
| 44 | t.Error("expected DomainVerified=false for new agent") |
| 45 | } |
| 46 | } |
| 47 | |
| 48 | func TestCreateAgentDuplicate(t *testing.T) { |
| 49 | pool := testutil.TestDB(t) |
nothing calls this directly
no test coverage detected