use of com.redhat.devtools.intellij.tektoncd.utils.model.actions.AddTriggerModel in project intellij-tekton by redhat-developer.
the class YAMLBuilderTest method checkTaskRunCreatedHasOutputResource.
@Test
public void checkTaskRunCreatedHasOutputResource() throws IOException {
String content = load("task8.yaml");
AddTriggerModel model = new AddTriggerModel(content, Collections.emptyList(), Collections.emptyList(), Collections.emptyList(), Collections.emptyList(), Collections.emptyList(), Collections.emptyMap());
ObjectNode taskRunNode = YAMLBuilder.createTaskRun(model);
assertEquals(taskRunNode.get("apiVersion").asText(), "tekton.dev/v1beta1");
assertEquals(taskRunNode.get("kind").asText(), "TaskRun");
assertEquals(taskRunNode.get("metadata").get("generateName").asText(), "foo-");
assertEquals(taskRunNode.get("spec").get("taskRef").get("name").asText(), "foo");
assertFalse(taskRunNode.get("spec").has("serviceAccountName"));
assertFalse(taskRunNode.get("spec").has("serviceAccountNames"));
assertFalse(taskRunNode.get("spec").has("params"));
assertTrue(taskRunNode.get("spec").has("resources"));
assertFalse(taskRunNode.get("spec").get("resources").has("inputs"));
assertEquals(taskRunNode.get("spec").get("resources").get("outputs").get(0).get("name").asText(), "resource1");
assertFalse(taskRunNode.get("spec").has("workspaces"));
}
use of com.redhat.devtools.intellij.tektoncd.utils.model.actions.AddTriggerModel in project intellij-tekton by redhat-developer.
the class YAMLBuilderTest method checkPipelineRunCreatedHasServiceAccount.
@Test
public void checkPipelineRunCreatedHasServiceAccount() throws IOException {
String content = load("pipeline1.yaml");
AddTriggerModel model = new AddTriggerModel(content, Collections.emptyList(), Collections.emptyList(), Collections.emptyList(), Collections.emptyList(), Collections.emptyList(), Collections.emptyMap());
model.setServiceAccount("sa");
ObjectNode pipelineRunNode = YAMLBuilder.createPipelineRun(model);
assertEquals(pipelineRunNode.get("apiVersion").asText(), "tekton.dev/v1beta1");
assertEquals(pipelineRunNode.get("kind").asText(), "PipelineRun");
assertEquals(pipelineRunNode.get("metadata").get("generateName").asText(), "foo-");
assertEquals(pipelineRunNode.get("spec").get("pipelineRef").get("name").asText(), "foo");
assertEquals(pipelineRunNode.get("spec").get("serviceAccountName").asText(), "sa");
assertFalse(pipelineRunNode.get("spec").has("serviceAccountNames"));
assertFalse(pipelineRunNode.get("spec").has("params"));
assertFalse(pipelineRunNode.get("spec").has("resources"));
assertFalse(pipelineRunNode.get("spec").has("workspaces"));
}
use of com.redhat.devtools.intellij.tektoncd.utils.model.actions.AddTriggerModel in project intellij-tekton by redhat-developer.
the class YAMLBuilderTest method checkTriggerTemplateCreatedWithInputs.
@Test
public void checkTriggerTemplateCreatedWithInputs() throws IOException {
String content = load("task1.yaml");
AddTriggerModel model = new AddTriggerModel(content, Collections.emptyList(), Collections.emptyList(), Collections.emptyList(), Collections.emptyList(), Collections.emptyList(), Collections.emptyMap());
ObjectNode taskRunNode = YAMLBuilder.createTaskRun(model);
ObjectNode triggerTemplateNode = YAMLBuilder.createTriggerTemplate("template", TRIGGER_BETA1_API_VERSION, Arrays.asList("param1", "param2"), Arrays.asList(taskRunNode));
assertEquals(triggerTemplateNode.get("apiVersion").asText(), TRIGGER_BETA1_API_VERSION);
assertEquals(triggerTemplateNode.get("kind").asText(), "TriggerTemplate");
assertEquals(triggerTemplateNode.get("metadata").get("name").asText(), "template");
assertTrue(triggerTemplateNode.get("spec").has("params"));
assertEquals(triggerTemplateNode.get("spec").get("params").get(0).get("name").asText(), "param1");
assertEquals(triggerTemplateNode.get("spec").get("params").get(1).get("name").asText(), "param2");
assertTrue(triggerTemplateNode.get("spec").has("resourcetemplates"));
}
use of com.redhat.devtools.intellij.tektoncd.utils.model.actions.AddTriggerModel in project intellij-tekton by redhat-developer.
the class YAMLBuilderTest method checkTaskRunCreatedHasWorkspace.
@Test
public void checkTaskRunCreatedHasWorkspace() throws IOException {
String content = load("task10.yaml");
AddTriggerModel model = new AddTriggerModel(content, Collections.emptyList(), Collections.emptyList(), Collections.emptyList(), Collections.emptyList(), Collections.emptyList(), Collections.emptyMap());
if (model.getWorkspaces().containsKey("write-allowed")) {
model.getWorkspaces().put("write-allowed", new Workspace("foo1", Workspace.Kind.EMPTYDIR, "foo"));
}
if (model.getWorkspaces().containsKey("write-disallowed")) {
model.getWorkspaces().put("write-disallowed", new Workspace("foo2", Workspace.Kind.EMPTYDIR, "foo"));
}
ObjectNode taskRunNode = YAMLBuilder.createTaskRun(model);
assertEquals(taskRunNode.get("apiVersion").asText(), "tekton.dev/v1beta1");
assertEquals(taskRunNode.get("kind").asText(), "TaskRun");
assertEquals(taskRunNode.get("metadata").get("generateName").asText(), "foo-");
assertEquals(taskRunNode.get("spec").get("taskRef").get("name").asText(), "foo");
assertFalse(taskRunNode.get("spec").has("serviceAccountName"));
assertFalse(taskRunNode.get("spec").has("serviceAccountNames"));
assertFalse(taskRunNode.get("spec").has("params"));
assertFalse(taskRunNode.get("spec").has("resources"));
assertTrue(taskRunNode.get("spec").has("workspaces"));
assertEquals(taskRunNode.get("spec").get("workspaces").get(0).get("name").asText(), "foo1");
assertEquals(taskRunNode.get("spec").get("workspaces").get(1).get("name").asText(), "foo2");
}
use of com.redhat.devtools.intellij.tektoncd.utils.model.actions.AddTriggerModel in project intellij-tekton by redhat-developer.
the class YAMLBuilderTest method checkTaskRunCreatedWithNoInputs.
// ///////////////////////////////////////////////////////
// / CREATE TASKRUN
// ///////////////////////////////////////////////////////
@Test
public void checkTaskRunCreatedWithNoInputs() throws IOException {
String content = load("task1.yaml");
AddTriggerModel model = new AddTriggerModel(content, Collections.emptyList(), Collections.emptyList(), Collections.emptyList(), Collections.emptyList(), Collections.emptyList(), Collections.emptyMap());
ObjectNode taskRunNode = YAMLBuilder.createTaskRun(model);
assertEquals(taskRunNode.get("apiVersion").asText(), "tekton.dev/v1beta1");
assertEquals(taskRunNode.get("kind").asText(), "TaskRun");
assertEquals(taskRunNode.get("metadata").get("generateName").asText(), "foo-");
assertEquals(taskRunNode.get("spec").get("taskRef").get("name").asText(), "foo");
assertFalse(taskRunNode.get("spec").has("serviceAccountName"));
assertFalse(taskRunNode.get("spec").has("serviceAccountNames"));
assertFalse(taskRunNode.get("spec").has("params"));
assertFalse(taskRunNode.get("spec").has("resources"));
assertFalse(taskRunNode.get("spec").has("workspaces"));
}
Aggregations