Skip to content

Commit

Permalink
Move some test helpers from docs_test to fish_test
Browse files Browse the repository at this point in the history
This is in preparation to make docs optional.

Backported from commit aabfea8

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
  • Loading branch information
kolyshkin committed May 3, 2022
1 parent f2ea22a commit b2f1549
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 67 deletions.
67 changes: 0 additions & 67 deletions docs_test.go
Original file line number Diff line number Diff line change
@@ -1,76 +1,9 @@
package cli

import (
"io/ioutil"
"testing"
)

func testApp() *App {
app := NewApp()
app.Name = "greet"
app.Flags = []Flag{
StringFlag{
Name: "socket, s",
Usage: "some 'usage' text",
Value: "value",
TakesFile: true,
},
StringFlag{Name: "flag, fl, f"},
BoolFlag{
Name: "another-flag, b",
Usage: "another usage text",
},
}
app.Commands = []Command{{
Aliases: []string{"c"},
Flags: []Flag{
StringFlag{
Name: "flag, fl, f",
TakesFile: true,
},
BoolFlag{
Name: "another-flag, b",
Usage: "another usage text",
},
},
Name: "config",
Usage: "another usage test",
Subcommands: []Command{{
Aliases: []string{"s", "ss"},
Flags: []Flag{
StringFlag{Name: "sub-flag, sub-fl, s"},
BoolFlag{
Name: "sub-command-flag, s",
Usage: "some usage text",
},
},
Name: "sub-config",
Usage: "another usage test",
}},
}, {
Aliases: []string{"i", "in"},
Name: "info",
Usage: "retrieve generic information",
}, {
Name: "some-command",
}, {
Name: "hidden-command",
Hidden: true,
}}
app.UsageText = "app [first_arg] [second_arg]"
app.Usage = "Some app"
app.Author = "Harrison"
app.Email = "harrison@lolwut.com"
app.Authors = []Author{{Name: "Oliver Allen", Email: "oliver@toyshop.com"}}
return app
}

func expectFileContent(t *testing.T, file, expected string) {
data, err := ioutil.ReadFile(file)
expect(t, err, nil)
expect(t, string(data), expected)
}

func TestToMarkdownFull(t *testing.T) {
// Given
app := testApp()
Expand Down
67 changes: 67 additions & 0 deletions fish_test.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,76 @@
package cli

import (
"io/ioutil"
"testing"
)

func testApp() *App {
app := NewApp()
app.Name = "greet"
app.Flags = []Flag{
StringFlag{
Name: "socket, s",
Usage: "some 'usage' text",
Value: "value",
TakesFile: true,
},
StringFlag{Name: "flag, fl, f"},
BoolFlag{
Name: "another-flag, b",
Usage: "another usage text",
},
}
app.Commands = []Command{{
Aliases: []string{"c"},
Flags: []Flag{
StringFlag{
Name: "flag, fl, f",
TakesFile: true,
},
BoolFlag{
Name: "another-flag, b",
Usage: "another usage text",
},
},
Name: "config",
Usage: "another usage test",
Subcommands: []Command{{
Aliases: []string{"s", "ss"},
Flags: []Flag{
StringFlag{Name: "sub-flag, sub-fl, s"},
BoolFlag{
Name: "sub-command-flag, s",
Usage: "some usage text",
},
},
Name: "sub-config",
Usage: "another usage test",
}},
}, {
Aliases: []string{"i", "in"},
Name: "info",
Usage: "retrieve generic information",
}, {
Name: "some-command",
}, {
Name: "hidden-command",
Hidden: true,
}}
app.UsageText = "app [first_arg] [second_arg]"
app.Usage = "Some app"
app.Author = "Harrison"
app.Email = "harrison@lolwut.com"
app.Authors = []Author{{Name: "Oliver Allen", Email: "oliver@toyshop.com"}}
return app
}

func expectFileContent(t *testing.T, file, expected string) {
data, err := ioutil.ReadFile(file)
expect(t, err, nil)
expect(t, string(data), expected)
}

func TestFishCompletion(t *testing.T) {
// Given
app := testApp()
Expand Down

0 comments on commit b2f1549

Please sign in to comment.