-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #60 from srl-labs/tests/util-tests
tests: simple tests for util funcs
- Loading branch information
Showing
20 changed files
with
744 additions
and
63 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
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
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,50 @@ | ||
package util_test | ||
|
||
import ( | ||
"testing" | ||
|
||
clabernetestesthelper "github.com/srl-labs/clabernetes/testhelper" | ||
clabernetesutil "github.com/srl-labs/clabernetes/util" | ||
) | ||
|
||
func TestAnyBoolTrue(t *testing.T) { | ||
cases := []struct { | ||
name string | ||
in []bool | ||
expected bool | ||
}{ | ||
{ | ||
name: "simple", | ||
in: []bool{true}, | ||
expected: true, | ||
}, | ||
{ | ||
name: "all-true", | ||
in: []bool{true, true, true}, | ||
expected: true, | ||
}, | ||
{ | ||
name: "one-true", | ||
in: []bool{false, true, false}, | ||
expected: true, | ||
}, | ||
{ | ||
name: "all-false", | ||
in: []bool{false, false, false}, | ||
expected: false, | ||
}, | ||
} | ||
|
||
for _, testCase := range cases { | ||
t.Run( | ||
testCase.name, | ||
func(t *testing.T) { | ||
t.Logf("%s: starting", testCase.name) | ||
|
||
actual := clabernetesutil.AnyBoolTrue(testCase.in...) | ||
if actual != testCase.expected { | ||
clabernetestesthelper.FailOutput(t, actual, testCase.expected) | ||
} | ||
}) | ||
} | ||
} |
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 util_test | ||
|
||
import ( | ||
"testing" | ||
|
||
clabernetestesthelper "github.com/srl-labs/clabernetes/testhelper" | ||
clabernetesutil "github.com/srl-labs/clabernetes/util" | ||
) | ||
|
||
func TestHashBytes(t *testing.T) { | ||
cases := []struct { | ||
name string | ||
in []byte | ||
expected string | ||
}{ | ||
{ | ||
name: "simple", | ||
in: []byte("hashmeplz"), | ||
expected: "b370f837831aa6b19d65cac4a0f8ef13e8d145027d3b95992232ccb8f0e564b5", | ||
}, | ||
} | ||
|
||
for _, testCase := range cases { | ||
t.Run( | ||
testCase.name, | ||
func(t *testing.T) { | ||
t.Logf("%s: starting", testCase.name) | ||
|
||
actual := clabernetesutil.HashBytes(testCase.in) | ||
if actual != testCase.expected { | ||
clabernetestesthelper.FailOutput(t, actual, testCase.expected) | ||
} | ||
}) | ||
} | ||
} |
Oops, something went wrong.