use of com.redhat.devtools.intellij.tektoncd.tkn.component.field.Input in project intellij-tekton by redhat-developer.
the class TknCliTest method checkRightArgsWhenStartingClusterTaskWithMultipleInputs.
@Test
public void checkRightArgsWhenStartingClusterTaskWithMultipleInputs() throws IOException {
Map<String, Input> params = new HashMap<>();
params.put("param1", new Input("param1", "string", Input.Kind.PARAMETER, "value1", Optional.empty(), Optional.empty()));
Map<String, String> inputResources = new HashMap<>();
inputResources.put("res1", "value1");
inputResources.put("res2", "value2");
Map<String, String> outputResources = new HashMap<>();
outputResources.put("out1", "value1");
Map<String, Workspace> workspaces = new HashMap<>();
workspaces.put("work1", new Workspace("work1", Workspace.Kind.PVC, "value1"));
workspaces.put("work2", new Workspace("work2", Workspace.Kind.SECRET, "value2"));
MockedStatic<ExecHelper> exec = mockStatic(ExecHelper.class);
exec.when(() -> ExecHelper.execute(anyString(), anyMap(), any())).thenReturn("");
tkn.startClusterTask("ns", "name", params, inputResources, outputResources, "sa", workspaces, "prefix");
exec.verify(() -> ExecHelper.execute(anyString(), anyMap(), eq("clustertask"), eq("start"), eq("name"), eq("-n"), eq("ns"), eq("-s=sa"), eq("-w"), eq("name=work2,secret=value2"), eq("-w"), eq("name=work1,claimName=value1"), eq("-p"), eq("param1=value1"), eq("-i"), eq("res1=value1"), eq("-i"), eq("res2=value2"), eq("-o"), eq("out1=value1"), eq("--prefix-name=prefix"), eq(FLAG_SKIP_OPTIONAL_WORKSPACES)));
exec.close();
}
use of com.redhat.devtools.intellij.tektoncd.tkn.component.field.Input in project intellij-tekton by redhat-developer.
the class TknCliTest method checkRightArgsWhenStartingTaskWithParameters.
@Test
public void checkRightArgsWhenStartingTaskWithParameters() throws IOException {
Map<String, Input> params = new HashMap<>();
params.put("param1", new Input("param1", "string", Input.Kind.PARAMETER, "value1", Optional.empty(), Optional.empty()));
params.put("param2", new Input("param2", "string", Input.Kind.PARAMETER, "value2", Optional.empty(), Optional.empty()));
MockedStatic<ExecHelper> exec = mockStatic(ExecHelper.class);
exec.when(() -> ExecHelper.execute(anyString(), anyMap(), any())).thenReturn("");
tkn.startTask("ns", "name", params, Collections.emptyMap(), Collections.emptyMap(), "", Collections.emptyMap(), "");
exec.verify(() -> ExecHelper.execute(anyString(), anyMap(), eq("task"), eq("start"), eq("name"), eq("-n"), eq("ns"), eq("-p"), eq("param1=value1"), eq("-p"), eq("param2=value2"), eq(FLAG_SKIP_OPTIONAL_WORKSPACES)));
exec.close();
}
use of com.redhat.devtools.intellij.tektoncd.tkn.component.field.Input in project intellij-tekton by redhat-developer.
the class TknCliPipelineTest method verifyStartPipelineCreateRuns.
@Test
public void verifyStartPipelineCreateRuns() throws IOException, InterruptedException, TimeoutException, ExecutionException {
String TASK_NAME = "add-task";
String PIPELINE_NAME = "sum-three-pipeline";
String taskConfig = TestUtils.load("start/add-task.yaml");
String pipelineConfig = TestUtils.load("start/sum-pipeline.yaml");
TestUtils.saveResource(tkn, taskConfig, NAMESPACE, "tasks");
TestUtils.saveResource(tkn, pipelineConfig, NAMESPACE, "pipelines");
// verify task has been created
List<String> tasks = tkn.getTasks(NAMESPACE).stream().map(task -> task.getMetadata().getName()).collect(Collectors.toList());
assertTrue(tasks.contains(TASK_NAME));
// verify pipeline has been created
List<String> pipelines = tkn.getPipelines(NAMESPACE).stream().map(pp -> pp.getMetadata().getName()).collect(Collectors.toList());
;
assertTrue(pipelines.contains(PIPELINE_NAME));
// start pipeline and verify taskrun and pipelinerun has been created
Map<String, Input> params = new HashMap<>();
params.put("first", new Input("name", "string", Input.Kind.PARAMETER, "value", Optional.empty(), Optional.empty()));
params.put("second", new Input("name2", "string", Input.Kind.PARAMETER, "value2", Optional.empty(), Optional.empty()));
params.put("third", new Input("name3", "string", Input.Kind.PARAMETER, "value3", Optional.empty(), Optional.empty()));
tkn.startPipeline(NAMESPACE, PIPELINE_NAME, params, Collections.emptyMap(), "", Collections.emptyMap(), Collections.emptyMap(), "");
final String[] namePipelineRun = { "" };
Watch watch = tkn.getClient(TektonClient.class).v1beta1().pipelineRuns().inNamespace(NAMESPACE).withLabel("tekton.dev/pipeline", PIPELINE_NAME).watch(createWatcher((resource) -> {
namePipelineRun[0] = resource.getMetadata().getName();
}));
stopAndWaitOnConditionOrTimeout(watch, () -> namePipelineRun[0].isEmpty());
assertFalse(namePipelineRun[0].isEmpty());
try {
// pipelinerun may have already finished its execution
tkn.cancelPipelineRun(NAMESPACE, namePipelineRun[0]);
} catch (IOException ignored) {
}
// clean up
tkn.deletePipelines(NAMESPACE, Arrays.asList(PIPELINE_NAME), true);
tkn.deleteTasks(NAMESPACE, Arrays.asList(TASK_NAME), false);
}
Aggregations