diff options
Diffstat (limited to 'client/client_test.go')
-rw-r--r-- | client/client_test.go | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/client/client_test.go b/client/client_test.go index ea2a7b5..b0309c7 100644 --- a/client/client_test.go +++ b/client/client_test.go @@ -4,12 +4,37 @@ package client import ( + "fmt" "io" + "net/http" + "net/http/httptest" "testing" + + "ricketyspace.net/peach/version" ) func TestGet(t *testing.T) { - res, err := Get("https://plan.cat/~s") + ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + // Check user-agent header. + expectedUA := fmt.Sprintf("peach/%s peach.ricketyspace.net", + version.Version) + if r.Header.Get("User-Agent") != expectedUA { + t.Errorf("header: user agent: %v != %v", + r.Header.Get("User-Agent"), expectedUA) + return + } + + // Check cache-control header. + if r.Header.Get("Cache-Control") != "max-age=0" { + t.Errorf("header: cache control: %v != max-age=0", + r.Header.Get("Cache-Control")) + return + } + fmt.Fprint(w, "OK") + })) + defer ts.Close() + + res, err := Get(ts.URL) if err != nil { t.Errorf("get failed: %v", err) return |