You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
66 lines
1.7 KiB
66 lines
1.7 KiB
package dao |
|
|
|
import ( |
|
"testing" |
|
|
|
"github.com/smartystreets/goconvey/convey" |
|
) |
|
|
|
func TestDaoConcatCondition(t *testing.T) { |
|
convey.Convey("ConcatCondition", t, func(ctx convey.C) { |
|
var ( |
|
conditions Condition = Condition{Key: "id", Operator: "=", Value: 1} |
|
) |
|
ctx.Convey("When everything goes positive", func(ctx convey.C) { |
|
conditionStr, args, hasOperator := ConcatCondition(conditions) |
|
ctx.Convey("Then conditionStr,args,hasOperator should not be nil.", func(ctx convey.C) { |
|
ctx.So(hasOperator, convey.ShouldNotBeNil) |
|
ctx.So(args, convey.ShouldNotBeNil) |
|
ctx.So(conditionStr, convey.ShouldNotBeNil) |
|
}) |
|
}) |
|
}) |
|
} |
|
|
|
func TestDaoAndCondition(t *testing.T) { |
|
convey.Convey("AndCondition", t, func(ctx convey.C) { |
|
var ( |
|
conditions Condition |
|
) |
|
ctx.Convey("When everything goes positive", func(ctx convey.C) { |
|
result := AndCondition(conditions) |
|
ctx.Convey("Then result should not be nil.", func(ctx convey.C) { |
|
ctx.So(result, convey.ShouldNotBeNil) |
|
}) |
|
}) |
|
}) |
|
} |
|
|
|
func TestDaoOrCondition(t *testing.T) { |
|
convey.Convey("OrCondition", t, func(ctx convey.C) { |
|
var ( |
|
conditions Condition |
|
) |
|
ctx.Convey("When everything goes positive", func(ctx convey.C) { |
|
result := OrCondition(conditions) |
|
ctx.Convey("Then result should not be nil.", func(ctx convey.C) { |
|
ctx.So(result, convey.ShouldNotBeNil) |
|
}) |
|
}) |
|
}) |
|
} |
|
|
|
func TestDaoaddLogicOperator(t *testing.T) { |
|
convey.Convey("addLogicOperator", t, func(ctx convey.C) { |
|
var ( |
|
operator = int(0) |
|
conditions Condition |
|
) |
|
ctx.Convey("When everything goes positive", func(ctx convey.C) { |
|
result := addLogicOperator(operator, conditions) |
|
ctx.Convey("Then result should not be nil.", func(ctx convey.C) { |
|
ctx.So(result, convey.ShouldNotBeNil) |
|
}) |
|
}) |
|
}) |
|
}
|
|
|