Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
skelouse committed Jan 29, 2023
1 parent e496537 commit 75a20d4
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 35 deletions.
31 changes: 0 additions & 31 deletions app_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2303,37 +2303,6 @@ func TestApp_VisibleCategories(t *testing.T) {
expect(t, []CommandCategory{}, app.VisibleCategories())
}

func TestApp_VisibleFlagCategories(t *testing.T) {
app := &App{
Flags: []Flag{
&StringFlag{
Name: "strd", // no category set
},
&Int64Flag{
Name: "intd",
Aliases: []string{"altd1", "altd2"},
Category: "cat1",
},
},
}
app.Setup()
vfc := app.VisibleFlagCategories()
if len(vfc) != 1 {
t.Fatalf("unexpected visible flag categories %+v", vfc)
}
if vfc[0].Name() != "cat1" {
t.Errorf("expected category name cat1 got %s", vfc[0].Name())
}
if len(vfc[0].Flags()) != 1 {
t.Fatalf("expected flag category to have just one flag got %+v", vfc[0].Flags())
}

fl := vfc[0].Flags()[0]
if !reflect.DeepEqual(fl.Names(), []string{"intd", "altd1", "altd2"}) {
t.Errorf("unexpected flag %+v", fl.Names())
}
}

func TestApp_Run_DoesNotOverwriteErrorFromBefore(t *testing.T) {
app := &App{
Action: func(c *Context) error { return nil },
Expand Down
8 changes: 4 additions & 4 deletions command_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -470,17 +470,17 @@ func TestCommand_VisibleFlagCategories(t *testing.T) {
}

vfc := c.VisibleFlagCategories()
if len(vfc) != 1 {
if len(vfc) != 2 {
t.Fatalf("unexpected visible flag categories %+v", vfc)
}
if vfc[0].Name() != "cat1" {
if vfc[1].Name() != "cat1" {
t.Errorf("expected category name cat1 got %s", vfc[0].Name())
}
if len(vfc[0].Flags()) != 1 {
if len(vfc[1].Flags()) != 1 {
t.Fatalf("expected flag category to have just one flag got %+v", vfc[0].Flags())
}

fl := vfc[0].Flags()[0]
fl := vfc[1].Flags()[0]
if !reflect.DeepEqual(fl.Names(), []string{"intd", "altd1", "altd2"}) {
t.Errorf("unexpected flag %+v", fl.Names())
}
Expand Down

0 comments on commit 75a20d4

Please sign in to comment.