MCPcopy Create free account
hub / github.com/mpolden/echoip / TestCLIMatcher

Function TestCLIMatcher

http/http_test.go:287–314  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

285}
286
287func TestCLIMatcher(t *testing.T) {
288 browserUserAgent := "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_4) " +
289 "AppleWebKit/537.36 (KHTML, like Gecko) Chrome/30.0.1599.28 " +
290 "Safari/537.36"
291 var tests = []struct {
292 in string
293 out bool
294 }{
295 {"curl/7.26.0", true},
296 {"Wget/1.13.4 (linux-gnu)", true},
297 {"Wget", true},
298 {"fetch libfetch/2.0", true},
299 {"HTTPie/0.9.3", true},
300 {"httpie-go/0.6.0", true},
301 {"Go 1.1 package http", true},
302 {"Go-http-client/1.1", true},
303 {"Go-http-client/2.0", true},
304 {"ddclient/3.8.3", true},
305 {"Mikrotik/6.x Fetch", true},
306 {browserUserAgent, false},
307 }
308 for _, tt := range tests {
309 r := &http.Request{Header: http.Header{"User-Agent": []string{tt.in}}}
310 if got := cliMatcher(r); got != tt.out {
311 t.Errorf("Expected %t, got %t for %q", tt.out, got, tt.in)
312 }
313 }
314}

Callers

nothing calls this directly

Calls 1

cliMatcherFunction · 0.85

Tested by

no test coverage detected