-
Notifications
You must be signed in to change notification settings - Fork 5
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 #31 from rezakhademix/add-validtor-test
added: validato test
- Loading branch information
Showing
1 changed file
with
41 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,41 @@ | ||
package validator | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func Test_msg(t *testing.T) { | ||
tests := []struct { | ||
name string | ||
method string | ||
msg string | ||
expectedMsg string | ||
}{ | ||
{ | ||
name: "test not exists method will result a panic", | ||
method: "qwert", | ||
msg: "", | ||
expectedMsg: "method message does not exist", | ||
}, | ||
{ | ||
name: "test empty string method will result a panic", | ||
method: "", | ||
msg: "", | ||
expectedMsg: "method message does not exist", | ||
}, | ||
{ | ||
name: "test empty space string method will result a panic", | ||
method: " ", | ||
msg: "", | ||
expectedMsg: "method message does not exist", | ||
}, | ||
} | ||
|
||
v := New() | ||
|
||
for _, test := range tests { | ||
assert.PanicsWithError(t, test.expectedMsg, func() { v.msg(test.method, test.msg) }) | ||
} | ||
} |