mirror of
https://github.com/gohugoio/hugo.git
synced 2025-04-29 07:00:31 +03:00
commands: Make commands.Execute return a Response object
We have no global `Hugo` object no more (yay!), and there are some external tools that depends on that value. These tools need to use get that value from `Response.Result`. Note that `commands.Execute` now also takes the arguments as a string slice. This should also make it easier to use, not having to modify `os.Args`. This commit also wraps up this particular issue. Phew! Test coverage in /commands before: 14.4% Now: 53.5% Still work to do, now it is at least possible. Closes #4598
This commit is contained in:
parent
e7010c1b62
commit
96689a5c31
4 changed files with 75 additions and 22 deletions
|
@ -23,6 +23,24 @@ import (
|
|||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func TestExecute(t *testing.T) {
|
||||
|
||||
assert := require.New(t)
|
||||
|
||||
dir, err := createSimpleTestSite(t)
|
||||
assert.NoError(err)
|
||||
|
||||
defer func() {
|
||||
os.RemoveAll(dir)
|
||||
}()
|
||||
|
||||
resp := Execute([]string{"-s=" + dir})
|
||||
assert.NoError(resp.Err)
|
||||
result := resp.Result
|
||||
assert.True(len(result.Sites) == 1)
|
||||
assert.True(len(result.Sites[0].RegularPages) == 1)
|
||||
}
|
||||
|
||||
func TestCommands(t *testing.T) {
|
||||
|
||||
assert := require.New(t)
|
||||
|
@ -72,7 +90,7 @@ func TestCommands(t *testing.T) {
|
|||
|
||||
for _, test := range tests {
|
||||
|
||||
hugoCmd := newHugoCompleteCmd()
|
||||
hugoCmd := newHugoCompleteCmd().getCommand()
|
||||
test.flags = append(test.flags, "--quiet")
|
||||
hugoCmd.SetArgs(append(test.commands, test.flags...))
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue