Skip to content
Myr

add test for c.Name() if c.Use gets changed (#548)

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Di Xu · committed by Eric Paris · parent 40f1880 · Browse files · 1 file+12 added−0 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+12 added−0 removed

  • other:+12 added−0 removed

1 file+12 added−0 removed

modified:command_test.go+12 added
484 unmodified lines
485 t.Errorf("expected %v, got %v", expected, err.Error())486 }487 }488}489490// TestUpdateName checks if c.Name() updates on changed c.Use.491// Related to https://github.com/spf13/cobra/pull/422#discussion_r143918343.492func TestUpdateName(t *testing.T) {493 c := &Command{Use: "name xyz"}494 originalName := c.Name()495496 c.Use = "changedName abc"497 if originalName == c.Name() || c.Name() != "changedName" {498 t.Error("c.Name() should be updated on changed c.Use")499 }500}