-
Notifications
You must be signed in to change notification settings - Fork 159
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Archishmaan Peyyety <archishou@gmail.com>
- Loading branch information
Showing
1 changed file
with
49 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package types | ||
|
||
import ( | ||
"testing" | ||
"errors" | ||
"fmt" | ||
log "github.com/sirupsen/logrus" | ||
) | ||
type TestTypesMatrixEntry struct { | ||
safename string | ||
url string | ||
sha string | ||
filename string | ||
err error | ||
ts TriState | ||
value string | ||
} | ||
|
||
func TestParseTriState(t *testing.T) { | ||
log.Infof("TestLookupIoBundle: START\n") | ||
testMatrix := []TestTypesMatrixEntry{ | ||
{err: nil, ts: TS_NONE, value: "none"}, | ||
|
||
{err: nil, ts: TS_ENABLED, value: "enable"}, | ||
{err: nil, ts: TS_ENABLED, value: "enabled"}, | ||
{err: nil, ts: TS_ENABLED, value: "on"}, | ||
|
||
{err: nil, ts: TS_DISABLED, value: "disabled"}, | ||
{err: nil, ts: TS_DISABLED, value: "disable"}, | ||
{err: nil, ts: TS_DISABLED, value: "off"}, | ||
|
||
{err: errors.New(fmt.Sprintf("Bad value: bad-value")), ts: TS_NONE, value: "bad-value"}, | ||
} | ||
|
||
for index := range testMatrix { | ||
entry := &testMatrix[index] | ||
ts, err := ParseTriState(entry.value) | ||
if ts != entry.ts { | ||
t.Errorf("Test Entry Index %d Failed: Expected TS: %s, Actual TS: %s\n", | ||
index, entry.ts, ts) | ||
} else if err == nil && entry.err == nil { | ||
|
||
} else if err.Error() != entry.err.Error() { | ||
t.Errorf("Test Entry Index %d Failed: Expected Error: %e, Actual Error: %e\n", | ||
index, entry.err, err) | ||
} else {} | ||
} | ||
log.Infof("TestLookupIoBundle: DONE\n") | ||
} |