def xtest_task_description(): t1 = totkn.Task("secret-env-task", description="the description") t1.params = [totkn.Param()] click.echo(t1.params) t1.steps = [totkn.Step(image="ubuntu")] d = task_dict("secret-env-task") d["metadata"]["annotations"] = {"description": "the description"} verify(d, t1) t2 = totkn.Task("secret-env-task") t2.description("the description") t2.steps.append(totkn.Step(image="ubuntu")) verify(d, t2)
def test_task_steps() -> None: step = totkn.Step() step.image = "ubuntu" step.name = "echo" step.command = ["echo"] step.args = ["01 version"] task = totkn.Task("the-task") task.steps = [step] verify( """ apiVersion: tekton.dev/v1beta1 kind: Task metadata: name: the-task spec: steps: - name: echo image: ubuntu command: - echo args: - "01 version" """, task, )
def test_pipeline_str() -> None: task = totkn.Task("mytask") p = totkn.Pipeline(name="pipelinename") p.tasks = [PipelineTask("ptask", task.ref())] pt = totkn.PipelineTask() pt.name = "pipeline-taskref-name" verify( """ apiVersion: tekton.dev/v1beta1 kind: Pipeline metadata: name: pipelinename spec: tasks: - name: ptask taskRef: name: mytask """, p, )
def test_trigger() -> None: task = totkn.Task("mytask") p = totkn.Pipeline(name="pipeline") p.tasks = [PipelineTask("ptask", task.ref())] pt = totkn.PipelineTask() pt.name = "pipeline-taskref-name" pr = PipelineRun("pipelinerun-$(uid)") pr.pipelineRef = p.ref() verify( """ apiVersion: tekton.dev/v1beta1 kind: PipelineRun metadata: name: pipelinerun-$(uid) spec: pipelineRef: name: pipeline """, pr, ) tt = TriggerTemplate("theTemplateTrigger") tt.resourcetemplates = [pr] verify( """ apiVersion: tekton.dev/v1alpha1 kind: TriggerTemplate metadata: name: theTemplateTrigger spec: resourcetemplates: - apiVersion: tekton.dev/v1beta1 kind: PipelineRun metadata: name: pipelinerun-$(uid) spec: pipelineRef: name: pipeline """, tt, )
def test_task_missing_step() -> None: task = totkn.Task("mytask") try: task.to_yaml() except MissingAttribute as ma: assert isinstance(ma, MissingAttribute)
def test_task_str() -> None: step = totkn.Step("ubuntu") task = totkn.Task("mytask") task.steps = [step] verify(ubuntu_task_str, task)