Skip to content

Commit

Permalink
Allow job artifacts to be retrieved from the mock
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
eds-collabora committed Nov 25, 2022
1 parent e7288ea commit d0f1858
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions gitlab-runner-mock/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,16 @@ impl GitlabRunnerMock {
jobs.jobs.push(job);
}

pub fn get_job_artifact(&self, id: u64) -> Option<Vec<u8>> {
let jobs = self.inner.jobs.lock().unwrap();

jobs
.jobs
.iter()
.find(|j| j.id() == id)
.map(|j| j.artifact().as_slice().to_vec())
}

fn grab_pending_job(&self) -> Option<MockJob> {
let jobs = self.inner.jobs.lock().unwrap();
for job in jobs.jobs.iter() {
Expand Down

0 comments on commit d0f1858

Please sign in to comment.