|
1 | | -package auth |
| 1 | +package auth |
2 | 2 |
|
3 | 3 | import ( |
4 | | - "fmt" |
5 | | - "net/http" |
6 | | - "testing" |
| 4 | + "fmt" |
| 5 | + "net/http" |
| 6 | + "testing" |
7 | 7 | ) |
8 | 8 |
|
9 | 9 | func TestGetAPIKey(t *testing.T) { |
10 | | - tests := []struct{ |
11 | | - name string |
12 | | - header http.Header |
13 | | - want string |
14 | | - wantErr bool |
| 10 | + tests := []struct { |
| 11 | + name string |
| 12 | + header http.Header |
| 13 | + want string |
| 14 | + wantErr bool |
15 | 15 | }{ |
16 | | - { |
17 | | - name: "missing auth header", |
18 | | - header: http.Header{"Authorization": []string{""}}, |
19 | | - want: "", |
20 | | - wantErr: true, |
21 | | - }, |
| 16 | + { |
| 17 | + name: "missing auth header", |
| 18 | + header: http.Header{"Authorization": []string{""}}, |
| 19 | + want: "", |
| 20 | + wantErr: true, |
| 21 | + }, |
22 | 22 | } |
23 | 23 |
|
24 | | - for _, tc := range tests { |
25 | | - got, err := GetAPIKey(tc.header) |
26 | | - if (err != nil) != tc.wantErr { |
27 | | - fmt.Sprintf("Got issue in test case %s", tc.name) |
28 | | - t.Fatalf("expected error: %v, got %v", tc.wantErr, err) |
| 24 | + for _, tc := range tests { |
| 25 | + got, err := GetAPIKey(tc.header) |
| 26 | + if (err != nil) != tc.wantErr { |
| 27 | + fmt.Sprintf("Got issue in test case %s", tc.name) |
| 28 | + t.Fatalf("expected error: %v, got %v", tc.wantErr, err) |
| 29 | + } |
| 30 | + if got != tc.want { |
| 31 | + t.Errorf("expected: %q, got %q", tc.want, got) |
| 32 | + } |
29 | 33 | } |
30 | | - if got != tc.want { |
31 | | - t.Errorf("expected: %q, got %q", tc.want, got) |
32 | | - } |
33 | | - } |
34 | 34 | } |
0 commit comments