-
Notifications
You must be signed in to change notification settings - Fork 216
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into add-kernelversion-to-traces
- Loading branch information
Showing
6 changed files
with
97 additions
and
36 deletions.
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
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,33 @@ | ||
package main | ||
|
||
import ( | ||
"bytes" | ||
"testing" | ||
|
||
"github.com/microsoft/retina/cli/cmd" | ||
"github.com/spf13/cobra" | ||
"github.com/stretchr/testify/assert" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func ExecuteInTest(cmd *cobra.Command, args []string) (stdout string, stderr string, err error) { | ||
var stdoutBuf, stderrBuf bytes.Buffer | ||
cmd.SetArgs(args) | ||
cmd.SetOut(&stdoutBuf) | ||
cmd.SetErr(&stderrBuf) | ||
defer func() { | ||
cmd.SetArgs(nil) | ||
cmd.SetOut(nil) | ||
cmd.SetErr(nil) | ||
}() | ||
|
||
err = cmd.Execute() | ||
return stdoutBuf.String(), stderrBuf.String(), err | ||
} | ||
|
||
func TestCLICmd(t *testing.T) { | ||
stdout, stderr, err := ExecuteInTest(cmd.Retina, []string{"-h"}) | ||
require.NoError(t, err) | ||
assert.Contains(t, stdout, "kubectl-retina") | ||
assert.Equal(t, stderr, "") | ||
} |
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