(t *testing.T)
| 228 | } |
| 229 | |
| 230 | func TestCmdValidate_Failures(t *testing.T) { |
| 231 | ctx := context.Background() |
| 232 | |
| 233 | // Missing agent email → rejected before any DB work. |
| 234 | if err := cmdValidate(ctx, config{}); err == nil { |
| 235 | t.Error("validate without agent email should fail") |
| 236 | } |
| 237 | |
| 238 | // DB reachable + migrations recorded, but the probe identity is absent. |
| 239 | // RunMigrations populates schema_migrations (testutil applies DDL only) so |
| 240 | // cmdValidate's migrations-applied check passes and reaches the identity check. |
| 241 | pool := testutil.TestDB(t) |
| 242 | if err := identity.RunMigrations(ctx, pool, migrations.FS, identity.ModeAuto); err != nil { |
| 243 | t.Fatalf("record migrations: %v", err) |
| 244 | } |
| 245 | err := cmdValidate(ctx, config{ |
| 246 | DatabaseURL: testutil.TestDBURL(), |
| 247 | AgentEmail: "missing@nowhere.test", |
| 248 | }) |
| 249 | if err == nil || !strings.Contains(err.Error(), "not found") { |
| 250 | t.Errorf("validate with missing identity: err = %v, want a not-found error", err) |
| 251 | } |
| 252 | } |
nothing calls this directly
no test coverage detected