Skip to content

Commit

Permalink
Move taskrun logs to v1
Browse files Browse the repository at this point in the history
This will move taskrun logs to v1 and
add tests for task and taskrun

Part of tektoncd#1804
  • Loading branch information
piyush-garg committed Mar 25, 2023
1 parent d8f34da commit 0701117
Show file tree
Hide file tree
Showing 9 changed files with 2,712 additions and 522 deletions.
89 changes: 0 additions & 89 deletions pkg/cmd/clustertask/logs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -203,92 +203,3 @@ func TestLogs_Auto_Select_FirstClusterTask(t *testing.T) {
t.Error("No auto selection of the first ClusterTask when we have only one")
}
}

func TestClusterTaskLog_v1beta1(t *testing.T) {
clock := clockwork.NewFakeClock()

ctask1 := []*v1beta1.ClusterTask{
{
ObjectMeta: metav1.ObjectMeta{
Name: "task",
},
},
}
cs, _ := test.SeedV1beta1TestData(t, pipelinev1beta1test.Data{
ClusterTasks: ctask1,
})
cs.Pipeline.Resources = cb.APIResourceList(versionB1, []string{"clustertask", "taskrun"})
tdc1 := testDynamic.Options{}
dc1, err := tdc1.Client(
cb.UnstructuredV1beta1CT(ctask1[0], versionB1),
)
if err != nil {
t.Errorf("unable to create dynamic client: %v", err)
}

if err != nil {
t.Errorf("unable to create dynamic client: %v", err)
}

testParams := []struct {
name string
command []string
input pipelinev1beta1test.Clients
dc dynamic.Interface
wantError bool
want string
}{
{
name: "Found no taskruns",
command: []string{"logs", "task", "-n", "ns"},
input: cs,
dc: dc1,
wantError: true,
want: "Command \"logs\" is deprecated, ClusterTasks are deprecated, this command will be removed in future releases.\nError: no TaskRuns found for ClusterTask task\n",
},
{
name: "Specify notexist task name",
command: []string{"logs", "notexist", "-n", "ns"},
input: cs,
dc: dc1,
wantError: true,
want: "Command \"logs\" is deprecated, ClusterTasks are deprecated, this command will be removed in future releases.\nError: clustertasks.tekton.dev \"notexist\" not found\n",
},
{
name: "Specify notexist taskrun name",
command: []string{"logs", "task", "notexist", "-n", "ns"},
input: cs,
dc: dc1,
wantError: true,
want: "Command \"logs\" is deprecated, ClusterTasks are deprecated, this command will be removed in future releases.\nError: Unable to get TaskRun: taskruns.tekton.dev \"notexist\" not found\n",
},
{
name: "Specify negative number to limit",
command: []string{"logs", "task", "-n", "ns", "--limit", "-1"},
input: cs,
dc: dc1,
wantError: true,
want: "Command \"logs\" is deprecated, ClusterTasks are deprecated, this command will be removed in future releases.\nError: limit was -1 but must be a positive number\n",
},
}

for _, tp := range testParams {
t.Run(tp.name, func(t *testing.T) {
p := &test.Params{Tekton: tp.input.Pipeline, Clock: clock, Kube: tp.input.Kube, Dynamic: tp.dc}
c := Command(p)

out, err := test.ExecuteCommand(c, tp.command...)
if tp.wantError {
if err == nil {
t.Errorf("error expected here")
}
test.AssertOutput(t, tp.want, out)
} else {
if err != nil {
t.Errorf("unexpected Error")
}
test.AssertOutput(t, tp.want, out)
}
})
}
}
Loading

0 comments on commit 0701117

Please sign in to comment.