/usr/share/gocode/src/github.com/coreos/pkg/httputil/cookie_test.go is in golang-github-coreos-pkg-dev 0.0~git20151028.0.2c77715-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 | package httputil
import (
"net/http"
"net/http/httptest"
"testing"
"time"
)
func TestDeleteCookies(t *testing.T) {
tests := []struct {
// cookie names to delete
n []string
}{
// single
{
n: []string{"foo"},
},
// multiple
{
n: []string{"foo", "bar"},
},
}
for i, tt := range tests {
w := httptest.NewRecorder()
DeleteCookies(w, tt.n...)
resp := &http.Response{}
resp.Header = w.Header()
cks := resp.Cookies()
if len(cks) != len(tt.n) {
t.Errorf("case %d: unexpected number of cookies, want: %d, got: %d", i, len(tt.n), len(cks))
}
for _, c := range cks {
if c.Value != "" {
t.Errorf("case %d: unexpected cookie value, want: %q, got: %q", i, "", c.Value)
}
if c.Path != "/" {
t.Errorf("case %d: unexpected cookie path, want: %q, got: %q", i, "/", c.Path)
}
if c.MaxAge != -1 {
t.Errorf("case %d: unexpected cookie max-age, want: %q, got: %q", i, -1, c.MaxAge)
}
if !c.Expires.IsZero() {
t.Errorf("case %d: unexpected cookie expires, want: %q, got: %q", i, time.Time{}, c.MaxAge)
}
}
}
}
|