forked from tektoncd/cli
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This will add a flag type to resource list command which will list the resources filter by the given type It will show error in case of invalid type Add docs and tests Fix tektoncd#147
- Loading branch information
1 parent
72224f4
commit cefe60d
Showing
6 changed files
with
92 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,7 +26,7 @@ import ( | |
tb "github.com/tektoncd/pipeline/test/builder" | ||
) | ||
|
||
func TestPipelineResources(t *testing.T) { | ||
func TestPipelineResourceList(t *testing.T) { | ||
|
||
pres := []*v1alpha1.PipelineResource{ | ||
tb.PipelineResource("test-1", "test-ns-1", | ||
|
@@ -77,6 +77,36 @@ func TestPipelineResources(t *testing.T) { | |
"", | ||
}, | ||
}, | ||
{ | ||
name: "Single Pipeline Resource by type", | ||
command: command(t, pres), | ||
args: []string{"list", "-n", "test-ns-1", "-t", "git"}, | ||
expected: []string{ | ||
"NAME TYPE DETAILS", | ||
"test-2 git url: [email protected]:tektoncd/cli.git", | ||
"", | ||
}, | ||
}, | ||
{ | ||
name: "Multiple Pipeline Resource by type", | ||
command: command(t, pres), | ||
args: []string{"list", "-n", "test-ns-1", "-t", "image"}, | ||
expected: []string{ | ||
"NAME TYPE DETAILS", | ||
"test-1 image URL: quey.io/tekton/controller", | ||
"test-3 image ---", | ||
"", | ||
}, | ||
}, | ||
{ | ||
name: "Empty Pipeline Resource by type", | ||
command: command(t, pres), | ||
args: []string{"list", "-n", "test-ns-1", "-t", "storage"}, | ||
expected: []string{ | ||
"No pipelineresources found.", | ||
"", | ||
}, | ||
}, | ||
{ | ||
name: "By template", | ||
command: command(t, pres), | ||
|
@@ -103,14 +133,28 @@ func TestPipelineResources(t *testing.T) { | |
|
||
} | ||
|
||
func TestPipelineResource_empty(t *testing.T) { | ||
func TestPipelineResourceList_empty(t *testing.T) { | ||
cs, _ := pipelinetest.SeedTestData(t, pipelinetest.Data{}) | ||
p := &test.Params{Tekton: cs.Pipeline} | ||
pipelineresource := Command(p) | ||
out, _ := test.ExecuteCommand(pipelineresource, "list", "-n", "test-ns-3") | ||
tu.AssertOutput(t, msgNoPREsFound+"\n", out) | ||
} | ||
|
||
func TestPipelineResourceList_invalidType(t *testing.T) { | ||
cs, _ := pipelinetest.SeedTestData(t, pipelinetest.Data{}) | ||
p := &test.Params{Tekton: cs.Pipeline} | ||
c := Command(p) | ||
|
||
_, err := tu.ExecuteCommand(c, "list", "-n", "ns", "-t", "registry") | ||
|
||
if err == nil { | ||
t.Error("Expecting an error but it's empty") | ||
} | ||
|
||
tu.AssertOutput(t, "Failed to list pipelineresources. Invalid resource type registry", err.Error()) | ||
} | ||
|
||
func command(t *testing.T, pres []*v1alpha1.PipelineResource) *cobra.Command { | ||
cs, _ := pipelinetest.SeedTestData(t, pipelinetest.Data{PipelineResources: pres}) | ||
p := &test.Params{Tekton: cs.Pipeline} | ||
|