-
Notifications
You must be signed in to change notification settings - Fork 144
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: adding test in the root package in order to test the run command (
#733) * adding test in the root package in order to test the run command Signed-off-by: Fokion Sotiropoulos <[email protected]>
- Loading branch information
Showing
4 changed files
with
38 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package root | ||
|
||
import ( | ||
"os/exec" | ||
"path/filepath" | ||
"strings" | ||
"testing" | ||
|
||
"github.com/ovh/venom" | ||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
// getTopLevelFolder returns the top level folder of the project | ||
func getTopLevelFolder() string { | ||
out, err := exec.Command("go", "list", "-m", "-f", "{{.Dir}}").Output() | ||
if err != nil { | ||
panic(err) | ||
} | ||
return strings.TrimSpace(string(out)) | ||
} | ||
|
||
// TestRunCmd tests the run command | ||
func TestRunCmd(t *testing.T) { | ||
var validArgs []string | ||
|
||
validArgs = append(validArgs, "run", filepath.Join(getTopLevelFolder(), "tests", "assertions")) | ||
rootCmd := New() | ||
rootCmd.SetArgs(validArgs) | ||
venom.IsTest = "test" | ||
assert.Equal(t, 3, len(rootCmd.Commands())) | ||
err := rootCmd.Execute() | ||
assert.NoError(t, err) | ||
rootCmd.Execute() | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters