@marcel91200 / caddy Mirror · read-only
Fork 0

Fast and extensible multi-platform HTTP/1-2-3 web server with automatic HTTPS

Mirrored from https://github.com/Slazee/caddy.git

Synced Nov 11, 01:00 UTC

master
go 28 lines 633 Bytes
Raw
1 package metrics
2
3 import (
4 "strings"
5 "testing"
6 )
7
8 func TestSanitizeMethod(t *testing.T) {
9 tests := []struct {
10 method string
11 expected string
12 }{
13 {method: "get", expected: "GET"},
14 {method: "POST", expected: "POST"},
15 {method: "OPTIONS", expected: "OPTIONS"},
16 {method: "connect", expected: "CONNECT"},
17 {method: "trace", expected: "TRACE"},
18 {method: "UNKNOWN", expected: "OTHER"},
19 {method: strings.Repeat("ohno", 9999), expected: "OTHER"},
20 }
21
22 for _, d := range tests {
23 actual := SanitizeMethod(d.method)
24 if actual != d.expected {
25 t.Errorf("Not same: expected %#v, but got %#v", d.expected, actual)
26 }
27 }
28 }