(t *testing.T)
| 72 | } |
| 73 | |
| 74 | func TestGetSessionKeyFromAuth(t *testing.T) { |
| 75 | testCases := []struct { |
| 76 | authHeaderStr string |
| 77 | expected string |
| 78 | }{ |
| 79 | { |
| 80 | authHeaderStr: "Bearer foo", |
| 81 | expected: "foo", |
| 82 | }, |
| 83 | } |
| 84 | |
| 85 | for _, tc := range testCases { |
| 86 | // set up |
| 87 | r, err := http.NewRequest("GET", "/", nil) |
| 88 | if err != nil { |
| 89 | t.Fatal(errors.Wrap(err, "constructing request")) |
| 90 | } |
| 91 | |
| 92 | r.Header.Set("Authorization", tc.authHeaderStr) |
| 93 | |
| 94 | // execute |
| 95 | got, err := getSessionKeyFromAuth(r) |
| 96 | if err != nil { |
| 97 | t.Fatal(errors.Wrap(err, "executing")) |
| 98 | } |
| 99 | |
| 100 | assert.Equal(t, got, tc.expected, "result mismatch") |
| 101 | } |
| 102 | } |
| 103 | |
| 104 | func mustMakeRequest(t *testing.T) *http.Request { |
| 105 | r, err := http.NewRequest("GET", "/", nil) |
nothing calls this directly
no test coverage detected