|
|
|
@ -19,7 +19,10 @@ limitations under the License.
|
|
|
|
|
|
|
|
|
|
package main
|
|
|
|
|
|
|
|
|
|
import "testing"
|
|
|
|
|
import (
|
|
|
|
|
"fmt"
|
|
|
|
|
"testing"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
func Test_GetCmd(t *testing.T) {
|
|
|
|
|
tmpl := map[string]string{
|
|
|
|
@ -59,3 +62,76 @@ func Test_GetCmd(t *testing.T) {
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func Test_GetCmdErrors(t *testing.T) {
|
|
|
|
|
tmpl := map[string]string{
|
|
|
|
|
"fluxns": allocateNamespace("flux-system"),
|
|
|
|
|
}
|
|
|
|
|
testEnv.CreateObjectFile("./testdata/get/objects.yaml", tmpl, t)
|
|
|
|
|
|
|
|
|
|
tests := []struct {
|
|
|
|
|
name string
|
|
|
|
|
args string
|
|
|
|
|
assert assertFunc
|
|
|
|
|
}{
|
|
|
|
|
{
|
|
|
|
|
name: "specific object not found",
|
|
|
|
|
args: "get kustomization non-existent-resource -n " + tmpl["fluxns"],
|
|
|
|
|
assert: assertError(fmt.Sprintf("Kustomization object 'non-existent-resource' not found in \"%s\" namespace", tmpl["fluxns"])),
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: "no objects found in namespace",
|
|
|
|
|
args: "get helmrelease -n " + tmpl["fluxns"],
|
|
|
|
|
assert: assertError(fmt.Sprintf("no HelmRelease objects found in \"%s\" namespace", tmpl["fluxns"])),
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for _, tt := range tests {
|
|
|
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
|
|
|
cmd := cmdTestCase{
|
|
|
|
|
args: tt.args,
|
|
|
|
|
assert: tt.assert,
|
|
|
|
|
}
|
|
|
|
|
cmd.runTestCmd(t)
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func Test_GetCmdSuccess(t *testing.T) {
|
|
|
|
|
tmpl := map[string]string{
|
|
|
|
|
"fluxns": allocateNamespace("flux-system"),
|
|
|
|
|
}
|
|
|
|
|
testEnv.CreateObjectFile("./testdata/get/objects.yaml", tmpl, t)
|
|
|
|
|
|
|
|
|
|
tests := []struct {
|
|
|
|
|
name string
|
|
|
|
|
args string
|
|
|
|
|
assert assertFunc
|
|
|
|
|
}{
|
|
|
|
|
{
|
|
|
|
|
name: "list sources git",
|
|
|
|
|
args: "get sources git -n " + tmpl["fluxns"],
|
|
|
|
|
assert: assertSuccess(),
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: "get help",
|
|
|
|
|
args: "get --help",
|
|
|
|
|
assert: assertSuccess(),
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: "get with all namespaces flag",
|
|
|
|
|
args: "get sources git -A",
|
|
|
|
|
assert: assertSuccess(),
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for _, tt := range tests {
|
|
|
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
|
|
|
cmd := cmdTestCase{
|
|
|
|
|
args: tt.args,
|
|
|
|
|
assert: tt.assert,
|
|
|
|
|
}
|
|
|
|
|
cmd.runTestCmd(t)
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|