Skip to content

Commit

Permalink
Always show the number of deleted taskruns
Browse files Browse the repository at this point in the history
  • Loading branch information
colinodell committed Sep 8, 2022
1 parent abb5704 commit 618868f
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 18 deletions.
8 changes: 4 additions & 4 deletions pkg/cmd/taskrun/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ func deleteTaskRuns(s *cli.Stream, p cli.Params, trNames []string, opts *options
case opts.KeepSince > 0 && !opts.IgnoreRunning:
fmt.Fprintf(s.Out, "All but %d expired TaskRuns associated with %q %q deleted in namespace %q\n", numberOfDeletedTr, opts.ParentResource, opts.ParentResourceName, p.Namespace())
case opts.ParentResourceName != "" && !opts.IgnoreRunning:
fmt.Fprintf(s.Out, "All TaskRuns associated with %s %q deleted in namespace %q\n", opts.ParentResource, opts.ParentResourceName, p.Namespace())
fmt.Fprintf(s.Out, "All %d TaskRuns associated with %s %q deleted in namespace %q\n", numberOfDeletedTr, opts.ParentResource, opts.ParentResourceName, p.Namespace())
case opts.Keep > 0 && opts.KeepSince > 0:
fmt.Fprintf(s.Out, "%d TaskRuns(Completed) associated with %s %q has been deleted in namespace %q\n", numberOfDeletedTr, opts.ParentResource, opts.ParentResourceName, p.Namespace())
case opts.Keep > 0:
Expand All @@ -230,7 +230,7 @@ func deleteTaskRuns(s *cli.Stream, p cli.Params, trNames []string, opts *options
case opts.KeepSince > 0:
fmt.Fprintf(s.Out, "All but %d expired TaskRuns associated with %q %q deleted in namespace %q\n", numberOfDeletedTr, opts.ParentResource, opts.ParentResourceName, p.Namespace())
case opts.ParentResourceName != "":
fmt.Fprintf(s.Out, "All TaskRuns(Completed) associated with %s %q deleted in namespace %q\n", opts.ParentResource, opts.ParentResourceName, p.Namespace())
fmt.Fprintf(s.Out, "All %d TaskRuns(Completed) associated with %s %q deleted in namespace %q\n", numberOfDeletedTr, opts.ParentResource, opts.ParentResourceName, p.Namespace())
default:
d.PrintSuccesses(s)
}
Expand All @@ -251,9 +251,9 @@ func deleteTaskRuns(s *cli.Stream, p cli.Params, trNames []string, opts *options
case opts.KeepSince > 0:
fmt.Fprintf(s.Out, "%d expired Taskruns(Completed) has been deleted in namespace %q, kept %d\n", numberOfDeletedTr, p.Namespace(), numberOfKeptTr)
case !opts.IgnoreRunning:
fmt.Fprintf(s.Out, "All TaskRuns deleted in namespace %q\n", p.Namespace())
fmt.Fprintf(s.Out, "All %d TaskRuns deleted in namespace %q\n", numberOfDeletedTr, p.Namespace())
default:
fmt.Fprintf(s.Out, "All TaskRuns(Completed) deleted in namespace %q\n", p.Namespace())
fmt.Fprintf(s.Out, "All %d TaskRuns(Completed) deleted in namespace %q\n", numberOfDeletedTr, p.Namespace())
}
}
}
Expand Down
28 changes: 14 additions & 14 deletions pkg/cmd/taskrun/delete_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -544,7 +544,7 @@ func TestTaskRunDelete(t *testing.T) {
input: seeds[0].pipelineClient,
inputStream: strings.NewReader("y"),
wantError: false,
want: "Are you sure you want to delete all TaskRuns related to Task \"random\" (y/n): All TaskRuns(Completed) associated with Task \"random\" deleted in namespace \"ns\"\n",
want: "Are you sure you want to delete all TaskRuns related to Task \"random\" (y/n): All 3 TaskRuns(Completed) associated with Task \"random\" deleted in namespace \"ns\"\n",
},
{
name: "Delete all with prompt",
Expand All @@ -553,7 +553,7 @@ func TestTaskRunDelete(t *testing.T) {
input: seeds[3].pipelineClient,
inputStream: strings.NewReader("y"),
wantError: false,
want: "Are you sure you want to delete all TaskRuns in namespace \"ns\" (y/n): All TaskRuns(Completed) deleted in namespace \"ns\"\n",
want: "Are you sure you want to delete all TaskRuns in namespace \"ns\" (y/n): All 9 TaskRuns(Completed) deleted in namespace \"ns\"\n",
},
{
name: "Delete all with -f",
Expand All @@ -562,7 +562,7 @@ func TestTaskRunDelete(t *testing.T) {
input: seeds[4].pipelineClient,
inputStream: nil,
wantError: false,
want: "All TaskRuns(Completed) deleted in namespace \"ns\"\n",
want: "All 9 TaskRuns(Completed) deleted in namespace \"ns\"\n",
},
{
name: "Delete all keeping 2",
Expand Down Expand Up @@ -643,7 +643,7 @@ func TestTaskRunDelete(t *testing.T) {
input: seeds[0].pipelineClient,
inputStream: strings.NewReader("y"),
wantError: false,
want: "Are you sure you want to delete all TaskRuns related to ClusterTask \"random\" (y/n): All TaskRuns(Completed) associated with ClusterTask \"random\" deleted in namespace \"ns\"\n",
want: "Are you sure you want to delete all TaskRuns related to ClusterTask \"random\" (y/n): All 5 TaskRuns(Completed) associated with ClusterTask \"random\" deleted in namespace \"ns\"\n",
},
{
name: "Error from deleting TaskRun with non-existing ClusterTask",
Expand Down Expand Up @@ -742,7 +742,7 @@ func TestTaskRunDelete(t *testing.T) {
input: seeds[4].pipelineClient,
inputStream: nil,
wantError: false,
want: "All TaskRuns(Completed) deleted in namespace \"ns\"\n",
want: "All 0 TaskRuns(Completed) deleted in namespace \"ns\"\n",
},
{
name: "Delete all with explicit --ignore-running true",
Expand All @@ -751,16 +751,16 @@ func TestTaskRunDelete(t *testing.T) {
input: seeds[4].pipelineClient,
inputStream: nil,
wantError: false,
want: "All TaskRuns(Completed) deleted in namespace \"ns\"\n",
want: "All 0 TaskRuns(Completed) deleted in namespace \"ns\"\n",
},
{
name: "Delete all with --ignore-running false",
name: "Delete all with --ignore-running false",
command: []string{"delete", "--all", "-f", "-n", "ns", "--ignore-running=false"},
dynamic: seeds[4].dynamicClient,
input: seeds[4].pipelineClient,
inputStream: nil,
wantError: false,
want: "All TaskRuns deleted in namespace \"ns\"\n",
want: "All 4 TaskRuns deleted in namespace \"ns\"\n",
},
{
name: "Delete the Task present and give error for non-existent Task",
Expand All @@ -787,7 +787,7 @@ func TestTaskRunDelete(t *testing.T) {
input: seeds[11].pipelineClient,
inputStream: nil,
wantError: false,
want: "All TaskRuns(Completed) associated with Task \"random\" deleted in namespace \"ns\"\n",
want: "All 4 TaskRuns(Completed) associated with Task \"random\" deleted in namespace \"ns\"\n",
},
{
name: "Delete all of task with explicit --ignore-running true",
Expand All @@ -796,7 +796,7 @@ func TestTaskRunDelete(t *testing.T) {
input: seeds[12].pipelineClient,
inputStream: nil,
wantError: false,
want: "All TaskRuns(Completed) associated with Task \"random\" deleted in namespace \"ns\"\n",
want: "All 4 TaskRuns(Completed) associated with Task \"random\" deleted in namespace \"ns\"\n",
},
{
name: "Delete all of task with --ignore-running false",
Expand All @@ -805,7 +805,7 @@ func TestTaskRunDelete(t *testing.T) {
input: seeds[13].pipelineClient,
inputStream: nil,
wantError: false,
want: "All TaskRuns associated with Task \"random\" deleted in namespace \"ns\"\n",
want: "All 6 TaskRuns associated with Task \"random\" deleted in namespace \"ns\"\n",
},
{
name: "Delete all of clustertask with default --ignore-running",
Expand All @@ -814,7 +814,7 @@ func TestTaskRunDelete(t *testing.T) {
input: seeds[14].pipelineClient,
inputStream: nil,
wantError: false,
want: "All TaskRuns(Completed) associated with ClusterTask \"random\" deleted in namespace \"ns\"\n",
want: "All 5 TaskRuns(Completed) associated with ClusterTask \"random\" deleted in namespace \"ns\"\n",
},
{
name: "Delete all of clustertask with explicit --ignore-running true",
Expand All @@ -823,7 +823,7 @@ func TestTaskRunDelete(t *testing.T) {
input: seeds[15].pipelineClient,
inputStream: nil,
wantError: false,
want: "All TaskRuns(Completed) associated with ClusterTask \"random\" deleted in namespace \"ns\"\n",
want: "All 5 TaskRuns(Completed) associated with ClusterTask \"random\" deleted in namespace \"ns\"\n",
},
{
name: "Delete all of clustertask with --ignore-running false",
Expand All @@ -832,7 +832,7 @@ func TestTaskRunDelete(t *testing.T) {
input: seeds[16].pipelineClient,
inputStream: nil,
wantError: false,
want: "All TaskRuns associated with ClusterTask \"random\" deleted in namespace \"ns\"\n",
want: "All 7 TaskRuns associated with ClusterTask \"random\" deleted in namespace \"ns\"\n",
},
}

Expand Down

0 comments on commit 618868f

Please sign in to comment.