-
Notifications
You must be signed in to change notification settings - Fork 207
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move validation tests to vallie package
- Loading branch information
Akshay Shah
committed
May 25, 2017
1 parent
0428135
commit 681170a
Showing
2 changed files
with
35 additions
and
28 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 |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package vallie | ||
|
||
import ( | ||
"net/http" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestValidation(t *testing.T) { | ||
type nothing struct{} | ||
|
||
tests := []struct { | ||
desc string | ||
input []interface{} | ||
valid bool | ||
}{ | ||
{"empty input", []interface{}{}, true}, | ||
{"nil pointer", []interface{}{(*nothing)(nil)}, false}, | ||
{"zero value", []interface{}{nothing{}}, false}, | ||
{"non-zero value", []interface{}{5}, true}, | ||
{"mixed input", []interface{}{5, http.DefaultServeMux}, true}, | ||
} | ||
|
||
for _, tt := range tests { | ||
t.Run(tt.desc, func(t *testing.T) { | ||
assert.Equal( | ||
t, | ||
tt.valid, | ||
Validate(tt.input...) == nil, | ||
"unexpected validation result for %v", tt.input, | ||
) | ||
}) | ||
} | ||
} |