diff --git a/organization_test.go b/organization_test.go index 878ea7f..4faaf81 100644 --- a/organization_test.go +++ b/organization_test.go @@ -54,6 +54,34 @@ func Test_GetOrganizationStatus_OK(t *testing.T) { }, res) } +func Test_GetOrganizationStatus_Err_5xx(t *testing.T) { + assert := assert.New(t) + httpmock.Activate() + defer httpmock.DeactivateAndReset() + + httpmock.RegisterResponder(http.MethodGet, "https://redash.example.com/api/organization/status", func(req *http.Request) (*http.Response, error) { + return httpmock.NewStringResponse(http.StatusServiceUnavailable, "error"), nil + }) + + client, _ := redash.NewClient("https://redash.example.com", testRedashAPIKey) + _, err := client.GetOrganizationStatus(context.Background()) + assert.ErrorContains(err, "GET api/organization/status failed: HTTP status code not OK: 503\nerror") +} + +func Test_GetOrganizationStatus_IOErr(t *testing.T) { + assert := assert.New(t) + httpmock.Activate() + defer httpmock.DeactivateAndReset() + + httpmock.RegisterResponder(http.MethodGet, "https://redash.example.com/api/organization/status", func(req *http.Request) (*http.Response, error) { + return testIOErrResp, nil + }) + + client, _ := redash.NewClient("https://redash.example.com", testRedashAPIKey) + _, err := client.GetOrganizationStatus(context.Background()) + assert.ErrorContains(err, "Read response body failed: IO error") +} + func Test_GetOrganizationStatus_Acc(t *testing.T) { if !testAcc { t.Skip()