forked from flyteorg/flyte
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added unit test for covarage (flyteorg#83)
Signed-off-by: Yuvraj <code@evalsocket.dev>
- Loading branch information
Showing
12 changed files
with
202 additions
and
96 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,5 +5,4 @@ bin | |
.DS_Store | ||
_test | ||
./config.yaml | ||
docs/build/* | ||
cmd/get/temp-output-file | ||
docs/build/* |
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,32 @@ | ||
package config | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/flyteorg/flytectl/pkg/printer" | ||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestOutputFormat(t *testing.T) { | ||
c := &Config{ | ||
Output: "json", | ||
} | ||
result, err := c.OutputFormat() | ||
assert.Nil(t, err) | ||
assert.Equal(t, printer.OutputFormat(1), result) | ||
} | ||
|
||
func TestInvalidOutputFormat(t *testing.T) { | ||
c := &Config{ | ||
Output: "test", | ||
} | ||
var result printer.OutputFormat | ||
defer func() { | ||
if r := recover(); r != nil { | ||
assert.Equal(t, printer.OutputFormat(0), result) | ||
assert.NotNil(t, r) | ||
} | ||
}() | ||
result = c.MustOutputFormat() | ||
|
||
} |
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
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,17 @@ | ||
package adminutils | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestGetConfig(t *testing.T) { | ||
defaultConfig = &Config{ | ||
MaxRecords: 500, | ||
BatchSize: 100, | ||
} | ||
c := GetConfig() | ||
assert.Equal(t, defaultConfig.BatchSize, c.BatchSize) | ||
assert.Equal(t, defaultConfig.MaxRecords, c.MaxRecords) | ||
} |
This file was deleted.
Oops, something went wrong.
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,51 @@ | ||
package commandutils | ||
|
||
import ( | ||
"io" | ||
"strings" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
type TestCase struct { | ||
Input io.Reader `json:"input"` | ||
Output bool `json:"output"` | ||
} | ||
|
||
func TestAskForConfirmation(t *testing.T) { | ||
tests := []TestCase{ | ||
{ | ||
Input: strings.NewReader("yes"), | ||
Output: true, | ||
}, | ||
{ | ||
Input: strings.NewReader("y"), | ||
Output: true, | ||
}, | ||
{ | ||
Input: strings.NewReader("no"), | ||
Output: false, | ||
}, | ||
{ | ||
Input: strings.NewReader("n"), | ||
Output: false, | ||
}, | ||
{ | ||
Input: strings.NewReader("No"), | ||
Output: false, | ||
}, | ||
{ | ||
Input: strings.NewReader("Yes"), | ||
Output: true, | ||
}, | ||
{ | ||
Input: strings.NewReader(""), | ||
Output: false, | ||
}, | ||
} | ||
for _, test := range tests { | ||
answer := AskForConfirmation("Testing for yes", test.Input) | ||
assert.Equal(t, test.Output, answer) | ||
} | ||
} |
Oops, something went wrong.