TestHarnessForTask covers the column → adapter lookup. NULL and empty resolve to claude+nil error (back-compat). Unknown non-empty names resolve to nil+error so callers refuse rather than silently coerce.
(t *testing.T)
| 37 | // non-empty names resolve to nil+error so callers refuse rather |
| 38 | // than silently coerce. |
| 39 | func TestHarnessForTask(t *testing.T) { |
| 40 | cases := []struct { |
| 41 | name string |
| 42 | harness sql.NullString |
| 43 | want harness.Name |
| 44 | wantErr bool |
| 45 | }{ |
| 46 | {"null column → claude", sql.NullString{}, harness.NameClaude, false}, |
| 47 | {"empty string → claude", sql.NullString{Valid: true, String: ""}, harness.NameClaude, false}, |
| 48 | {"claude pin", sql.NullString{Valid: true, String: "claude"}, harness.NameClaude, false}, |
| 49 | {"unknown name → error", sql.NullString{Valid: true, String: "future"}, "", true}, |
| 50 | } |
| 51 | for _, tc := range cases { |
| 52 | t.Run(tc.name, func(t *testing.T) { |
| 53 | task := &flowdb.Task{Harness: tc.harness} |
| 54 | h, err := harnessForTask(task) |
| 55 | if tc.wantErr { |
| 56 | if err == nil { |
| 57 | t.Errorf("got nil error, want non-nil") |
| 58 | } |
| 59 | return |
| 60 | } |
| 61 | if err != nil { |
| 62 | t.Fatalf("unexpected error: %v", err) |
| 63 | } |
| 64 | if got := h.Name(); got != tc.want { |
| 65 | t.Errorf("got %v, want %v", got, tc.want) |
| 66 | } |
| 67 | }) |
| 68 | } |
| 69 | } |
| 70 | |
| 71 | // TestCmdDoPersistsHarnessOnBootstrap pins the contract: the first |
| 72 | // `flow do` on a previously-unbound task writes the chosen harness |
nothing calls this directly
no test coverage detected