Skip to content

Commit

Permalink
added utils.go test for status code !200
Browse files Browse the repository at this point in the history
  • Loading branch information
tjololo committed Dec 20, 2024
1 parent e560c15 commit 1899055
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions services/dis-apim-operator/internal/utils/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,5 +58,15 @@ var _ = Describe("Utils", func() {
_, err := getContentUrl(context.Background(), server.URL)
Expect(err).To(HaveOccurred())
})
It("should return an error for non-200 status codes", func() {
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(http.StatusNotFound)
}))
defer server.Close()

_, err := getContentUrl(context.Background(), server.URL)
Expect(err).To(HaveOccurred())
Expect(err.Error()).To(ContainSubstring("unexpected status code 404"))
})
})
})

0 comments on commit 1899055

Please sign in to comment.