File tree Expand file tree Collapse file tree 1 file changed +11
-2
lines changed Expand file tree Collapse file tree 1 file changed +11
-2
lines changed Original file line number Diff line number Diff line change 11package cmd
22
33import (
4+ "bytes"
45 "context"
56 "os"
7+ "strings"
68 "testing"
79
810 fn "knative.dev/func/pkg/functions"
@@ -303,16 +305,23 @@ func TestDelete_NameAndPathExclusivity(t *testing.T) {
303305 // Command with a Client constructor using the mock remover.
304306 cmd := NewDeleteCmd (NewTestClient (fn .WithRemover (remover )))
305307
308+ // Capture command output for inspection
309+ buf := new (bytes.Buffer )
310+ cmd .SetOut (buf )
311+ cmd .SetErr (buf )
312+
306313 // Execute the command simulating the invalid argument combination of both
307314 // a path and an explicit name.
308315 cmd .SetArgs ([]string {"-p" , "./testpath" , "testname" })
309316 err := cmd .Execute ()
310317 if err == nil {
311- // TODO should really either parse the output or use typed errors to ensure it's
312- // failing for the expected reason.
313318 t .Fatalf ("expected error on conflicting flags not received" )
314319 }
315320
321+ if ! strings .Contains (err .Error (), "only one of --path and [NAME] should be provided" ) {
322+ t .Fatalf ("unexpected error message: %v" , err )
323+ }
324+
316325 // Also fail if remover's .Remove is invoked.
317326 if remover .RemoveInvoked {
318327 t .Fatal ("fn.Remover invoked despite invalid combination and an error" )
You can’t perform that action at this time.
0 commit comments