优化单元测试
This commit is contained in:
parent
a69f3a1e01
commit
44e6c5cdcf
@ -27,6 +27,7 @@ func TestDefaultValidateRuleGenerateFunc(t *testing.T) {
|
|||||||
ParamList: nil,
|
ParamList: nil,
|
||||||
})
|
})
|
||||||
So(err, ShouldBeError)
|
So(err, ShouldBeError)
|
||||||
|
So(define.IsErr(err, define.ErrValidatorRuleIsEmpty.Error()), ShouldBeTrue)
|
||||||
So(res, ShouldBeEmpty)
|
So(res, ShouldBeEmpty)
|
||||||
})
|
})
|
||||||
Convey("传入规则无参数", t, func() {
|
Convey("传入规则无参数", t, func() {
|
||||||
@ -43,6 +44,7 @@ func TestDefaultValidateRuleGenerateFunc(t *testing.T) {
|
|||||||
ParamList: nil,
|
ParamList: nil,
|
||||||
})
|
})
|
||||||
So(err, ShouldBeError)
|
So(err, ShouldBeError)
|
||||||
|
So(define.IsErr(err, define.ErrValidatorRuleParamCntIsTooLess.Error()), ShouldBeTrue)
|
||||||
So(res, ShouldEqual, "")
|
So(res, ShouldEqual, "")
|
||||||
})
|
})
|
||||||
Convey("传入oneof枚举值构建成功", t, func() {
|
Convey("传入oneof枚举值构建成功", t, func() {
|
||||||
@ -59,6 +61,7 @@ func TestDefaultValidateRuleGenerateFunc(t *testing.T) {
|
|||||||
ParamList: []any{},
|
ParamList: []any{},
|
||||||
})
|
})
|
||||||
So(err, ShouldNotBeNil)
|
So(err, ShouldNotBeNil)
|
||||||
|
So(define.IsErr(err, define.ErrValidatorRuleParamCntIsTooLess.Error()), ShouldBeTrue)
|
||||||
So(res, ShouldBeEmpty)
|
So(res, ShouldBeEmpty)
|
||||||
})
|
})
|
||||||
Convey("传入RequiredIf枚举值 -> 参数奇数个", t, func() {
|
Convey("传入RequiredIf枚举值 -> 参数奇数个", t, func() {
|
||||||
@ -67,6 +70,7 @@ func TestDefaultValidateRuleGenerateFunc(t *testing.T) {
|
|||||||
ParamList: []any{1, 2, 3},
|
ParamList: []any{1, 2, 3},
|
||||||
})
|
})
|
||||||
So(err, ShouldNotBeNil)
|
So(err, ShouldNotBeNil)
|
||||||
|
So(define.IsErr(err, define.ErrValidatorRuleParamCntIsNotEven.Error()), ShouldBeTrue)
|
||||||
So(res, ShouldBeEmpty)
|
So(res, ShouldBeEmpty)
|
||||||
})
|
})
|
||||||
Convey("传入RequiredIf枚举值 -> 构建成功", t, func() {
|
Convey("传入RequiredIf枚举值 -> 构建成功", t, func() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user