(t *testing.T)
| 121 | } |
| 122 | |
| 123 | func TestContextWindowFromHeaders(t *testing.T) { |
| 124 | cases := []struct { |
| 125 | name string |
| 126 | val string |
| 127 | want int |
| 128 | }{ |
| 129 | {"missing", "", 0}, |
| 130 | {"valid", "262144", 262144}, |
| 131 | {"min boundary", "1024", 1024}, |
| 132 | {"too small", "1023", 0}, |
| 133 | {"too large", "9999999999", 0}, |
| 134 | {"negative", "-1", 0}, |
| 135 | {"garbage", "abc", 0}, |
| 136 | } |
| 137 | for _, tc := range cases { |
| 138 | t.Run(tc.name, func(t *testing.T) { |
| 139 | h := http.Header{} |
| 140 | if tc.val != "" { |
| 141 | h.Set("X-Context-Window", tc.val) |
| 142 | } |
| 143 | if got := ContextWindowFromHeaders(h); got != tc.want { |
| 144 | t.Fatalf("want %d, got %d", tc.want, got) |
| 145 | } |
| 146 | }) |
| 147 | } |
| 148 | } |
| 149 | |
| 150 | func TestAuthHeader(t *testing.T) { |
| 151 | if AuthHeader("hp_abc") != "Bearer hp_abc" { |
nothing calls this directly
no test coverage detected