Skip to content

Commit

Permalink
Merge pull request #31 from rezakhademix/add-validtor-test
Browse files Browse the repository at this point in the history
added: validato test
  • Loading branch information
rezakhademix authored Mar 6, 2024
2 parents 4a444b7 + c10b2c0 commit 5cd4e7b
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions validator_test.go
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) })
}
}

0 comments on commit 5cd4e7b

Please sign in to comment.