Skip to content

Commit

Permalink
fix files in horreumUpload step
Browse files Browse the repository at this point in the history
  • Loading branch information
willr3 committed May 18, 2023
1 parent 5ac5f77 commit 99d920d
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package jenkins.plugins.horreum.upload;

import java.io.IOException;
import java.util.Arrays;
import java.util.stream.Collectors;

import javax.inject.Inject;

Expand Down Expand Up @@ -102,7 +104,7 @@ public void setJsonFile(String jsonFile) {
}

public String getFiles() {
return config.getJsonFile();
return config.getFiles();
}

@DataBoundSetter
Expand Down
41 changes: 40 additions & 1 deletion src/test/java/jenkins/plugins/horreum/HorreumUploadStepTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@

import static io.hyperfoil.tools.HorreumTestClientExtension.dummyTest;
import static io.hyperfoil.tools.HorreumTestClientExtension.horreumClient;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.*;

import java.net.URL;
import java.util.Map;

import hudson.FilePath;
import org.jenkinsci.plugins.workflow.cps.CpsFlowDefinition;
import org.jenkinsci.plugins.workflow.job.WorkflowJob;
import org.jenkinsci.plugins.workflow.job.WorkflowRun;
Expand Down Expand Up @@ -42,4 +44,41 @@ public void testUpload() throws Exception {
assertEquals(1, summary.total);
assertEquals(1, summary.runs.size());
}

@Test
public void testUploadMultiple() throws Exception {
URL jsonResource1 = Thread.currentThread().getContextClassLoader().getResource("data/config-quickstart.jvm.json");
URL jsonResource2 = Thread.currentThread().getContextClassLoader().getResource("data/another-file.json");
WorkflowJob proj = j.jenkins.createProject(WorkflowJob.class, "Horreum-Upload-Pipeline");
FilePath folder = j.jenkins.getWorkspaceFor(proj).child("run");
folder.child("config-quickstart.jvm.json").copyFrom(jsonResource1);
folder.child("another-file.json").copyFrom(jsonResource2);
proj.setDefinition(new CpsFlowDefinition(
"node {\n" +
"def id = horreumUpload(\n" +
"credentials: '" + HorreumPluginTestBase.HORREUM_UPLOAD_CREDENTIALS + "',\n" +
"test: '" + dummyTest.name + "',\n" +
"owner: '" + dummyTest.owner + "',\n" +
"access: 'PUBLIC',\n" +
"start: '1970-01-01T00:00:00.00Z',\n" +
"stop: '1970-01-01T00:00:01.00Z',\n" +
"files: '**/*.json',\n"+
"addBuildInfo: true\n" +
")\n" +
"println(id)\n" +
"}\n",
true));
WorkflowRun run = proj.scheduleBuild2(0).get();
j.assertBuildStatusSuccess(run);
RunService.RunsSummary summary = horreumClient.runService.listTestRuns(dummyTest.id, false, null, null, "", null);
assertEquals(1, summary.total);
assertEquals(1, summary.runs.size());
Object runObject = horreumClient.runService.getRun(summary.runs.get(0).id,summary.runs.get(0).token);
assertNotNull(runObject);
assertTrue(runObject instanceof Map,"run should return a map");
Object data = ((Map)runObject).get("data");
assertNotNull(data);
assertTrue(data instanceof Map,"data should be a map");
assertEquals(2,((Map<?, ?>) data).size(),"data should have an entry for each file");
}
}

0 comments on commit 99d920d

Please sign in to comment.