mirror of
https://github.com/spf13/cobra
synced 2024-11-24 14:47:12 +00:00
add test for c.Name() if c.Use gets changed (#548)
This commit is contained in:
parent
40f18800b2
commit
7cd9cc6d44
1 changed files with 12 additions and 0 deletions
|
@ -486,3 +486,15 @@ func TestPersistentRequiredFlags(t *testing.T) {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
// TestUpdateName checks if c.Name() updates on changed c.Use.
|
||||
// Related to https://github.com/spf13/cobra/pull/422#discussion_r143918343.
|
||||
func TestUpdateName(t *testing.T) {
|
||||
c := &Command{Use: "name xyz"}
|
||||
originalName := c.Name()
|
||||
|
||||
c.Use = "changedName abc"
|
||||
if originalName == c.Name() || c.Name() != "changedName" {
|
||||
t.Error("c.Name() should be updated on changed c.Use")
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue