Skip to content

Commit 6c79602

Browse files
committed
Allow job artifacts to be retrieved from the mock
This is useful when testing whether the artifacts uploaded are as expected. In particular, we need this now to test whether masked artifacts are actually being masked as we expect them to be. Note that we are returning the raw binary of the zipfile, and we'll need to use the zipfile crate to actually interpret this data. That seems acceptable for now.
1 parent e7288ea commit 6c79602

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

gitlab-runner-mock/src/lib.rs

+9
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,15 @@ impl GitlabRunnerMock {
134134
jobs.jobs.push(job);
135135
}
136136

137+
pub fn get_job_artifact(&self, id: u64) -> Option<Vec<u8>> {
138+
let jobs = self.inner.jobs.lock().unwrap();
139+
140+
jobs.jobs
141+
.iter()
142+
.find(|j| j.id() == id)
143+
.map(|j| j.artifact().as_slice().to_vec())
144+
}
145+
137146
fn grab_pending_job(&self) -> Option<MockJob> {
138147
let jobs = self.inner.jobs.lock().unwrap();
139148
for job in jobs.jobs.iter() {

0 commit comments

Comments
 (0)