mirror of https://github.com/spf13/cobra.git
add test for c.Name() if c.Use gets changed (#548)
This commit is contained in:
parent
40f18800b2
commit
7cd9cc6d44
|
@ -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 New Issue