Skip to content

Commit

Permalink
add test for help command
Browse files Browse the repository at this point in the history
  • Loading branch information
yakuter committed Apr 12, 2022
1 parent 33d309c commit 48c9073
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 7 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,5 +101,5 @@ Generate Certificate
2. Add cert template format read from yaml file
3. Add verification of a CA and http endpoint
4. Add test for utils package
5. Add test for help package
6. Add certificate converter command like DER to PEM etc.
5. Add certificate converter command like DER to PEM etc.
6. Add Homebrew formula for MacOS (help wanted)
6 changes: 1 addition & 5 deletions commands/help/help.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,5 @@ func Action(c *cli.Context) error {
} else {
err = cli.ShowCommandHelp(c, c.Args().First())
}
if err != nil {
return err
}

return nil
return err
}
30 changes: 30 additions & 0 deletions commands/help/help_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package help_test

import (
"os"
"testing"

"github.com/yakuter/gossl/commands/help"
"github.com/yakuter/gossl/commands/key"

"github.com/stretchr/testify/require"
"github.com/urfave/cli/v2"
)

func TestHelp(t *testing.T) {
execName, err := os.Executable()
require.NoError(t, err)

app := &cli.App{
Commands: []*cli.Command{
help.Command(),
key.Command(),
},
}

testArgs := []string{execName, "help"}
require.NoError(t, app.Run(testArgs))

testArgs = []string{execName, "help", "key"}
require.NoError(t, app.Run(testArgs))
}

0 comments on commit 48c9073

Please sign in to comment.