-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* chore: address wsl linting * Update plugin_test.go Adding unit test coverage * Update plugin.go consolidated some functionality * Create plugin_test.go * Migrate to better unit testing * Update plugin.go * Update plugin.go * Update plugin_test.go * Update plugin_test.go * Update main.go * Update plugin_test.go
- Loading branch information
1 parent
7d6a973
commit 69d635a
Showing
5 changed files
with
396 additions
and
156 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
package mock | ||
|
||
import ( | ||
"errors" | ||
"io" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestStart(t *testing.T) { | ||
c := &Command{} | ||
assert.NoError(t, c.Start()) | ||
} | ||
|
||
func TestWait(t *testing.T) { | ||
t.Run("No Error", func(t *testing.T) { | ||
c := &Command{} | ||
assert.NoError(t, c.Wait()) | ||
}) | ||
t.Run("An Error", func(t *testing.T) { | ||
c := &Command{waitErr: errors.New("some error")} | ||
assert.ErrorContains(t, c.Wait(), "some error") | ||
}) | ||
} | ||
|
||
func TestString(t *testing.T) { | ||
c := &Command{} | ||
assert.Empty(t, c.String()) | ||
} | ||
|
||
func TestStdoutPipe(t *testing.T) { | ||
c := &Command{} | ||
result, err := c.StdoutPipe() | ||
require.NoError(t, err) | ||
|
||
b, err := io.ReadAll(result) | ||
assert.NoError(t, err) | ||
assert.Empty(t, b) | ||
} | ||
func TestStderrPipe(t *testing.T) { | ||
c := &Command{} | ||
result, err := c.StderrPipe() | ||
require.NoError(t, err) | ||
|
||
b, err := io.ReadAll(result) | ||
assert.NoError(t, err) | ||
assert.Empty(t, b) | ||
} | ||
|
||
func TestCommandBuilderWithError(t *testing.T) { | ||
result := CommandBuilderWithError(errors.New("some error"), nil, nil, nil) | ||
assert.ErrorContains(t, result("start").Wait(), "some error") | ||
} | ||
|
||
func TestThresholdError(t *testing.T) { | ||
th := &ThresholdError{} | ||
assert.Equal(t, th.ExitCode(), thresholdsBreachedExitCode) | ||
assert.Contains(t, th.Error(), "mock") | ||
} |
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
Oops, something went wrong.