mirror of
https://github.com/ahmetb/kubectx.git
synced 2025-06-21 13:09:24 +00:00
feat: added test
This commit is contained in:
parent
9717232900
commit
8857602f83
@ -45,7 +45,7 @@ func parseArgs(argv []string) Op {
|
|||||||
if len(argv) > 1 {
|
if len(argv) > 1 {
|
||||||
return InteractiveSwitchOp{SelfCmd: os.Args[0], Query: argv[1]}
|
return InteractiveSwitchOp{SelfCmd: os.Args[0], Query: argv[1]}
|
||||||
} else {
|
} else {
|
||||||
return UnsupportedOp{Err: fmt.Errorf("'-q' needs arguments")}
|
return UnsupportedOp{Err: fmt.Errorf("'-q' needs an argument")}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return UnsupportedOp{Err: fmt.Errorf("'-q' only works in interactive mode")}
|
return UnsupportedOp{Err: fmt.Errorf("'-q' only works in interactive mode")}
|
||||||
|
@ -78,6 +78,10 @@ func Test_parseArgs_new(t *testing.T) {
|
|||||||
{name: "too many args",
|
{name: "too many args",
|
||||||
args: []string{"a", "b", "c"},
|
args: []string{"a", "b", "c"},
|
||||||
want: UnsupportedOp{Err: fmt.Errorf("too many arguments")}},
|
want: UnsupportedOp{Err: fmt.Errorf("too many arguments")}},
|
||||||
|
{name: "missing query",
|
||||||
|
args: []string{"-q"},
|
||||||
|
want: UnsupportedOp{Err: fmt.Errorf("'-q' only works in interactive mode")},
|
||||||
|
},
|
||||||
}
|
}
|
||||||
for _, tt := range tests {
|
for _, tt := range tests {
|
||||||
t.Run(tt.name, func(t *testing.T) {
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
|
Loading…
Reference in New Issue
Block a user