Skip to content

Commit

Permalink
Add Unit Test to check for matching error message in Generate function
Browse files Browse the repository at this point in the history
Co-authored-by: Marco Franssen <marco.franssen@philips.com>
  • Loading branch information
Brend-Smits and marcofranssen committed Oct 12, 2021
1 parent 6338837 commit 933743a
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions cmd/slsa-provenance/cli/generate_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package cli_test

import (
"context"
"testing"

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

const (
ArtifactPathError = "no value found for required flag: -artifact_path"
)

func TestErrors(t *testing.T) {
cli := cli.Generate()
err := cli.Exec(context.Background(), make([]string, 0))

if err == nil {
t.Error("Expected an error but did not generate one")
} else {
if err.Error() != ArtifactPathError {
t.Errorf("Expected error to match: %s", ArtifactPathError)
}
}
}

0 comments on commit 933743a

Please sign in to comment.