diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index 257c66f..6f6f769 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -32,7 +32,7 @@ jobs: - name: Build run: go build -v ./... - name: Test - run: go test -v ./... + run: go test -v -cover ./... diff --git a/main_test.go b/main_test.go index 9cc4415..f97e7eb 100644 --- a/main_test.go +++ b/main_test.go @@ -311,3 +311,24 @@ func TestRun(t *testing.T) { t.Errorf("Expected 1 file in output dir, got %d", len(files)) } } + +// TestRunFetchError verifies run() returns an error when the +// initial budget list cannot be fetched. +func TestRunFetchError(t *testing.T) { + srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + w.WriteHeader(http.StatusInternalServerError) + })) + defer srv.Close() + + cfg := Config{ + Token: "tok", + BaseURL: srv.URL, + OutputDir: t.TempDir(), + Client: srv.Client(), + } + + _, err := run(cfg) + if err == nil { + t.Fatal("expected error from run but got nil") + } +}