(t *testing.T)
| 82 | } |
| 83 | |
| 84 | func TestFakeAgentServer_CustomError(t *testing.T) { |
| 85 | ctx := context.Background() |
| 86 | |
| 87 | server := api.NewFakeAgentServer() |
| 88 | defer server.Close() |
| 89 | |
| 90 | server.ReserveError = "reservation failed" |
| 91 | server.ReserveStatusCode = 500 |
| 92 | |
| 93 | client, err := api.NewAgentClient(ctx, api.AgentClientOpts{ |
| 94 | Token: "fake-token", |
| 95 | Endpoint: server.URL(), |
| 96 | StackID: "test-stack", |
| 97 | Logger: slog.Default(), |
| 98 | }) |
| 99 | if err != nil { |
| 100 | t.Fatalf("NewAgentClient() error = %v", err) |
| 101 | } |
| 102 | |
| 103 | jobIDs := []string{"job-1"} |
| 104 | result, _, err := client.ReserveJobs(ctx, []string{"job-1"}, 0) |
| 105 | if err == nil { |
| 106 | t.Errorf("ReserveJobs(ctx, %q) error = nil, want error", jobIDs) |
| 107 | } |
| 108 | if result != nil { |
| 109 | t.Errorf("ReserveJobs(ctx, %q) result = %v, want nil", jobIDs, result) |
| 110 | } |
| 111 | } |
| 112 | |
| 113 | func TestFakeAgentServer_CustomResult(t *testing.T) { |
| 114 | ctx := context.Background() |
nothing calls this directly
no test coverage detected