Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion cmd/describe.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ import (
fn "knative.dev/func/pkg/functions"
)

var ErrNameAndPathConflict = errors.New("cannot specify both name and path")

func NewDescribeCmd(newClient ClientFactory) *cobra.Command {
cmd := &cobra.Command{
Use: "describe <name>",
Expand Down Expand Up @@ -128,7 +130,7 @@ func newDescribeConfig(cmd *cobra.Command, args []string) (cfg describeConfig, e
// logically inconsistent to provide both a name and a path to source.
// Either use the function's local state on disk (--path), or specify
// a name and a namespace to ignore any local function source.
err = fmt.Errorf("only one of --path and [NAME] should be provided")
err = ErrNameAndPathConflict
}
return
}
Expand Down
4 changes: 3 additions & 1 deletion cmd/describe_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package cmd

import (
"context"
"errors"
"strings"
"testing"

Expand Down Expand Up @@ -126,8 +127,9 @@ func TestDescribe_NameAndPathExclusivity(t *testing.T) {
cmd := NewDescribeCmd(NewTestClient(fn.WithDescriber(d)))
cmd.SetArgs([]string{"-p", "./testpath", "testname"})
if err := cmd.Execute(); err == nil {
// TODO(lkingland): use a typed error
t.Fatalf("expected error on conflicting flags not received")
} else if !errors.Is(err, ErrNameAndPathConflict) {
t.Fatalf("expected ErrNameAndPathExclusivity, got %v", err)
}
if d.DescribeInvoked {
t.Fatal("describer was invoked when conflicting flags were provided")
Expand Down
Loading