(t *testing.T)
| 19 | ) |
| 20 | |
| 21 | func TestParseIssueNo(t *testing.T) { |
| 22 | testCases := []struct { |
| 23 | issue string |
| 24 | expectErr bool |
| 25 | expected int |
| 26 | }{ |
| 27 | { |
| 28 | issue: "gvisor.dev/issue/123", |
| 29 | expected: 123, |
| 30 | }, |
| 31 | { |
| 32 | issue: "gvisor.dev/issue/123/", |
| 33 | expected: 123, |
| 34 | }, |
| 35 | { |
| 36 | issue: "not a url", |
| 37 | expected: 0, |
| 38 | }, |
| 39 | { |
| 40 | issue: "gvisor.dev/issue//", |
| 41 | expectErr: true, |
| 42 | }, |
| 43 | } |
| 44 | |
| 45 | for _, tc := range testCases { |
| 46 | t.Run(tc.issue, func(t *testing.T) { |
| 47 | id, err := parseIssueNo(tc.issue) |
| 48 | if err != nil && !tc.expectErr { |
| 49 | t.Errorf("got error: %v", err) |
| 50 | } else if tc.expected != id { |
| 51 | t.Errorf("got: %v, want: %v", id, tc.expected) |
| 52 | } |
| 53 | }) |
| 54 | } |
| 55 | } |
nothing calls this directly
no test coverage detected
searching dependent graphs…