Watch
1
0
Fork
You've already forked pkg-proxy
1
mirror of https://github.com/git-pkgs/proxy.git synced 2026-09-16 07:42:05 -04:00
pkg-proxy/internal/handler/if_none_match_test.go

31 lines
728 B
Go
Raw Permalink Normal View History

2026-09-03 16:59:12 +01:00
package handler
import "testing"
func TestIfNoneMatchHits(t *testing.T) {
tests := []struct {
header string
etag string
want bool
}{
{`"abc"`, `"abc"`, true},
{`"abc"`, `"def"`, false},
{"", `"abc"`, false},
{`"abc"`, "", false},
{"*", `"abc"`, true},
{"*", "", false},
{`W/"abc"`, `"abc"`, true},
{`"abc"`, `W/"abc"`, true},
{`W/"abc"`, `W/"abc"`, true},
{`"abc", "def"`, `"def"`, true},
{`"abc","def"`, `"def"`, true},
{` "abc" , W/"def" `, `"def"`, true},
{`"abc", "def"`, `"ghi"`, false},
}
for _, tt := range tests {
if got := ifNoneMatchHits(tt.header, tt.etag); got != tt.want {
t.Errorf("ifNoneMatchHits(%q, %q) = %v, want %v", tt.header, tt.etag, got, tt.want)
}
}
}