diff options
author | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2018-04-11 20:17:28 +0200 |
---|---|---|
committer | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2018-04-11 20:37:08 +0200 |
commit | 96689a5c319f720368491226f034d0ff9585217c (patch) | |
tree | f2e14fcaa31154d72d50f9b75cce78ceab9dcfbc /commands/commands_test.go | |
parent | e7010c1b621d68ee53411a5ba8143d07b976d9fe (diff) |
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
Diffstat (limited to 'commands/commands_test.go')
-rw-r--r-- | commands/commands_test.go | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/commands/commands_test.go b/commands/commands_test.go index 7e590bea0..ea9d3f74d 100644 --- a/commands/commands_test.go +++ b/commands/commands_test.go @@ -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...)) |