| 17 | ) |
| 18 | |
| 19 | func Test_List(t *testing.T) { |
| 20 | reg := &httpmock.Registry{} |
| 21 | defer reg.Verify(t) |
| 22 | |
| 23 | reg.Register( |
| 24 | httpmock.REST("GET", "repos/OWNER/REPO/actions/runs/123/artifacts"), |
| 25 | httpmock.StringResponse(`{ |
| 26 | "total_count": 2, |
| 27 | "artifacts": [ |
| 28 | {"name": "artifact-1"}, |
| 29 | {"name": "artifact-2"} |
| 30 | ] |
| 31 | }`)) |
| 32 | |
| 33 | api := &apiPlatform{ |
| 34 | client: &http.Client{Transport: reg}, |
| 35 | repo: ghrepo.New("OWNER", "REPO"), |
| 36 | } |
| 37 | artifacts, err := api.List("123") |
| 38 | require.NoError(t, err) |
| 39 | |
| 40 | require.Equal(t, 2, len(artifacts)) |
| 41 | assert.Equal(t, "artifact-1", artifacts[0].Name) |
| 42 | assert.Equal(t, "artifact-2", artifacts[1].Name) |
| 43 | } |
| 44 | |
| 45 | func Test_List_perRepository(t *testing.T) { |
| 46 | reg := &httpmock.Registry{} |