Skip to content
This repository was archived by the owner on Apr 20, 2023. It is now read-only.

Commit 702602a

Browse files
committed
Add Status and StatusCode to mock responses
Go 1.6 errors if Responses don't have a valid status code, which meant these tests were failing. Fixes #38
1 parent 6f21ebc commit 702602a

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

‎httpcache_test.go‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -565,6 +565,8 @@ func (s *S) TestStaleIfErrorRequest(c *C) {
565565
now := time.Now()
566566
tmock := transportMock{
567567
response: &http.Response{
568+
Status: http.StatusText(http.StatusOK),
569+
StatusCode: http.StatusOK,
568570
Header: http.Header{
569571
"Date": []string{now.Format(time.RFC1123)},
570572
"Cache-Control": []string{"no-cache"},
@@ -595,6 +597,8 @@ func (s *S) TestStaleIfErrorRequestLifetime(c *C) {
595597
now := time.Now()
596598
tmock := transportMock{
597599
response: &http.Response{
600+
Status: http.StatusText(http.StatusOK),
601+
StatusCode: http.StatusOK,
598602
Header: http.Header{
599603
"Date": []string{now.Format(time.RFC1123)},
600604
"Cache-Control": []string{"no-cache"},
@@ -637,6 +641,8 @@ func (s *S) TestStaleIfErrorResponse(c *C) {
637641
now := time.Now()
638642
tmock := transportMock{
639643
response: &http.Response{
644+
Status: http.StatusText(http.StatusOK),
645+
StatusCode: http.StatusOK,
640646
Header: http.Header{
641647
"Date": []string{now.Format(time.RFC1123)},
642648
"Cache-Control": []string{"no-cache, stale-if-error"},
@@ -666,6 +672,8 @@ func (s *S) TestStaleIfErrorResponseLifetime(c *C) {
666672
now := time.Now()
667673
tmock := transportMock{
668674
response: &http.Response{
675+
Status: http.StatusText(http.StatusOK),
676+
StatusCode: http.StatusOK,
669677
Header: http.Header{
670678
"Date": []string{now.Format(time.RFC1123)},
671679
"Cache-Control": []string{"no-cache, stale-if-error=100"},

0 commit comments

Comments
 (0)