(t *testing.T)
| 14 | ) |
| 15 | |
| 16 | func Test_GetGistIDFromURL(t *testing.T) { |
| 17 | tests := []struct { |
| 18 | name string |
| 19 | url string |
| 20 | want string |
| 21 | wantErr bool |
| 22 | }{ |
| 23 | { |
| 24 | name: "url", |
| 25 | url: "https://gist.github.com/1234", |
| 26 | want: "1234", |
| 27 | }, |
| 28 | { |
| 29 | name: "url with username", |
| 30 | url: "https://gist.github.com/octocat/1234", |
| 31 | want: "1234", |
| 32 | }, |
| 33 | { |
| 34 | name: "url, specific file", |
| 35 | url: "https://gist.github.com/1234#file-test-md", |
| 36 | want: "1234", |
| 37 | }, |
| 38 | { |
| 39 | name: "invalid url", |
| 40 | url: "https://gist.github.com", |
| 41 | wantErr: true, |
| 42 | want: "Invalid gist URL https://gist.github.com", |
| 43 | }, |
| 44 | } |
| 45 | |
| 46 | for _, tt := range tests { |
| 47 | t.Run(tt.name, func(t *testing.T) { |
| 48 | id, err := GistIDFromURL(tt.url) |
| 49 | if tt.wantErr { |
| 50 | assert.Error(t, err) |
| 51 | assert.EqualError(t, err, tt.want) |
| 52 | return |
| 53 | } |
| 54 | assert.NoError(t, err) |
| 55 | |
| 56 | assert.Equal(t, tt.want, id) |
| 57 | }) |
| 58 | } |
| 59 | } |
| 60 | |
| 61 | func TestIsBinaryContents(t *testing.T) { |
| 62 | tests := []struct { |
nothing calls this directly
no test coverage detected