7
7
using System . Threading . Tasks ;
8
8
using Cake . Common . Build . GitHubActions . Commands ;
9
9
using Cake . Common . Build . GitHubActions . Commands . Artifact ;
10
- using Cake . Common . Build . GitHubActions . Data ;
11
10
using Cake . Common . Tests . Fakes ;
12
11
using Cake . Core ;
13
12
using Cake . Core . IO ;
@@ -22,21 +21,45 @@ internal sealed class GitHubActionsCommandsFixture : HttpMessageHandler
22
21
private const string ArtifactUrl = GitHubActionsInfoFixture . ActionResultsUrl + "twirp/github.actions.results.api.v1.ArtifactService/" ;
23
22
private const string CreateArtifactUrl = ArtifactUrl + "CreateArtifact" ;
24
23
private const string FinalizeArtifactUrl = ArtifactUrl + "FinalizeArtifact" ;
25
- private const string GetSignedArtifactURLurl = ArtifactUrl + "GetSignedArtifactURL" ;
24
+ private const string GetSignedArtifactURLUrl = ArtifactUrl + "GetSignedArtifactURL" ;
25
+ private const string ListArtifactsUrl = ArtifactUrl + "ListArtifacts" ;
26
26
private const string UploadFileUrl = "https://cake.build.net/actions-results/a9d82106-d5d5-4310-8f60-0bfac035cf02/workflow-job-run-1d849a45-2f30-5fbb-3226-b730a17a93af/artifacts/91e64594182918fa8012cdbf7d1a4f801fa0c35f485c3277268aad8e3f45377c.zip?sig=upload" ;
27
27
private const string DownloadFileUrl = "https://cake.build.net/actions-results/a9d82106-d5d5-4310-8f60-0bfac035cf02/workflow-job-run-1d849a45-2f30-5fbb-3226-b730a17a93af/artifacts/91e64594182918fa8012cdbf7d1a4f801fa0c35f485c3277268aad8e3f45377c.zip?sig=download" ;
28
- private const string CreateArtifactResponse = @"{
29
- ""ok"": true,
30
- ""signed_upload_url"": """ + UploadFileUrl + @"""
31
- }" ;
32
- private const string FinalizeArtifactResponse = @"{
33
- ""ok"": true,
34
- ""artifact_id"": ""1991105334""
35
- }" ;
36
- private const string GetSignedArtifactURLResponse = @"{
37
- ""name"": ""artifact"",
38
- ""signed_url"": """ + DownloadFileUrl + @"""
39
- }" ;
28
+ private const string CreateArtifactResponse =
29
+ $$ """
30
+ {
31
+ "ok": true,
32
+ "signed_upload_url": "{{ UploadFileUrl }} "
33
+ }
34
+ """ ;
35
+ private const string FinalizeArtifactResponse =
36
+ """
37
+ {
38
+ "ok": true,
39
+ "artifact_id": "1991105334"
40
+ }
41
+ """ ;
42
+ private const string GetSignedArtifactURLResponse =
43
+ $$ """
44
+ {
45
+ "name": "artifact",
46
+ "signed_url": "{{ DownloadFileUrl }} "
47
+ }
48
+ """ ;
49
+ private const string ListArtifactsResponse =
50
+ $$ """
51
+ {
52
+ "artifacts": [
53
+ {
54
+ "workflow_run_backend_id": "b9e28153-ca20-4b86-91dd-09e8f644efdf",
55
+ "workflow_job_run_backend_id": "1d849a45-2f30-5fbb-3226-b730a17a93af",
56
+ "database_id": "1",
57
+ "name": "artifact",
58
+ "created_at": "2024-11-09T21:53:00.7110204+00:00"
59
+ }
60
+ ]
61
+ }
62
+ """ ;
40
63
41
64
private GitHubActionsInfoFixture GitHubActionsInfoFixture { get ; }
42
65
private ICakeEnvironment Environment { get ; }
@@ -122,7 +145,7 @@ protected override async Task<HttpResponseMessage> SendAsync(HttpRequestMessage
122
145
// Get Signed Artifact Url
123
146
case
124
147
{
125
- RequestUri : { AbsoluteUri : GetSignedArtifactURLurl } ,
148
+ RequestUri : { AbsoluteUri : GetSignedArtifactURLUrl } ,
126
149
Method : { Method : "POST" } ,
127
150
} :
128
151
{
@@ -189,6 +212,16 @@ protected override async Task<HttpResponseMessage> SendAsync(HttpRequestMessage
189
212
return Ok ( ) ;
190
213
}
191
214
215
+ // List Artifacts
216
+ case
217
+ {
218
+ RequestUri : { AbsoluteUri : ListArtifactsUrl } ,
219
+ Method : { Method : "POST" }
220
+ } :
221
+ {
222
+ return Ok ( new StringContent ( ListArtifactsResponse ) ) ;
223
+ }
224
+
192
225
// Download File
193
226
case
194
227
{
0 commit comments