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