Skip to content

Commit

Permalink
Refactor Generate Command to cobra cli lib
Browse files Browse the repository at this point in the history
Signed-off-by: Marco Franssen <marco.franssen@philips.com>
  • Loading branch information
marcofranssen committed Nov 30, 2021
1 parent cf2d451 commit dca7236
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
16 changes: 16 additions & 0 deletions cmd/slsa-provenance/cli/commands_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package cli_test

import (
"testing"

"github.com/stretchr/testify/assert"

"github.com/philips-labs/slsa-provenance-action/cmd/slsa-provenance/cli"
)

func TestCli(t *testing.T) {
assert := assert.New(t)

cli := cli.New()
assert.Len(cli.Commands(), 2)
}
21 changes: 21 additions & 0 deletions cmd/slsa-provenance/cli/generate_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package cli_test

import (
"testing"

"github.com/stretchr/testify/assert"

"github.com/philips-labs/slsa-provenance-action/cmd/slsa-provenance/cli"
)

func TestGenerate(t *testing.T) {
assert := assert.New(t)

cmd := cli.Generate()

assert.Len(cmd.Commands(), 2)
output, err := executeCommand(cmd)

assert.NoError(err)
assert.Contains(output, "Generate provenance using subcommands\n\nUsage:\n")
}

0 comments on commit dca7236

Please sign in to comment.