mirror of
				https://github.com/caddyserver/caddy.git
				synced 2025-10-31 10:37:24 -04:00 
			
		
		
		
	
		
			
				
	
	
		
			29 lines
		
	
	
		
			633 B
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			29 lines
		
	
	
		
			633 B
		
	
	
	
		
			Go
		
	
	
	
	
	
| package metrics
 | |
| 
 | |
| import (
 | |
| 	"strings"
 | |
| 	"testing"
 | |
| )
 | |
| 
 | |
| func TestSanitizeMethod(t *testing.T) {
 | |
| 	tests := []struct {
 | |
| 		method   string
 | |
| 		expected string
 | |
| 	}{
 | |
| 		{method: "get", expected: "GET"},
 | |
| 		{method: "POST", expected: "POST"},
 | |
| 		{method: "OPTIONS", expected: "OPTIONS"},
 | |
| 		{method: "connect", expected: "CONNECT"},
 | |
| 		{method: "trace", expected: "TRACE"},
 | |
| 		{method: "UNKNOWN", expected: "OTHER"},
 | |
| 		{method: strings.Repeat("ohno", 9999), expected: "OTHER"},
 | |
| 	}
 | |
| 
 | |
| 	for _, d := range tests {
 | |
| 		actual := SanitizeMethod(d.method)
 | |
| 		if actual != d.expected {
 | |
| 			t.Errorf("Not same: expected %#v, but got %#v", d.expected, actual)
 | |
| 		}
 | |
| 	}
 | |
| }
 |