github.com/MontFerret/ferret@v0.18.0/pkg/stdlib/testing/gt_test.go (about) 1 package testing_test 2 3 import ( 4 "context" 5 t "testing" 6 7 . "github.com/smartystreets/goconvey/convey" 8 9 "github.com/MontFerret/ferret/pkg/runtime/core" 10 "github.com/MontFerret/ferret/pkg/runtime/values" 11 "github.com/MontFerret/ferret/pkg/stdlib/testing" 12 "github.com/MontFerret/ferret/pkg/stdlib/testing/base" 13 ) 14 15 func TestGt(t *t.T) { 16 Gt := base.NewPositiveAssertion(testing.Gt) 17 18 Convey("When arg is not passed", t, func() { 19 Convey("It should return an error", func() { 20 _, err := Gt(context.Background()) 21 22 So(err, ShouldBeError) 23 24 _, err = Gt(context.Background(), values.NewInt(1)) 25 26 So(err, ShouldBeError) 27 }) 28 }) 29 30 Convey("When args are numbers", t, func() { 31 Convey("When 1 and 2", func() { 32 Convey("It should return an error", func() { 33 _, err := Gt(context.Background(), values.NewInt(1), values.NewInt(2)) 34 35 So(err, ShouldBeError) 36 So(err.Error(), ShouldEqual, core.Error(base.ErrAssertion, "expected [int] '1' to be greater than [int] '2'").Error()) 37 }) 38 }) 39 40 Convey("When 1 and 1", func() { 41 Convey("It should return an error", func() { 42 _, err := Gt(context.Background(), values.NewInt(1), values.NewInt(1)) 43 44 So(err, ShouldBeError) 45 So(err.Error(), ShouldEqual, core.Error(base.ErrAssertion, "expected [int] '1' to be greater than [int] '1'").Error()) 46 }) 47 }) 48 49 Convey("When 2 and 1", func() { 50 Convey("It should not return an error", func() { 51 _, err := Gt(context.Background(), values.NewInt(2), values.NewInt(1)) 52 53 So(err, ShouldBeNil) 54 }) 55 }) 56 }) 57 } 58 59 func TestNotGt(t *t.T) { 60 NotGt := base.NewNegativeAssertion(testing.Gt) 61 62 Convey("When arg is not passed", t, func() { 63 Convey("It should return an error", func() { 64 _, err := NotGt(context.Background()) 65 66 So(err, ShouldBeError) 67 68 _, err = NotGt(context.Background(), values.NewInt(1)) 69 70 So(err, ShouldBeError) 71 }) 72 }) 73 74 Convey("When args are numbers", t, func() { 75 Convey("When 2 and 1", func() { 76 Convey("It should return an error", func() { 77 _, err := NotGt(context.Background(), values.NewInt(2), values.NewInt(1)) 78 79 So(err, ShouldBeError) 80 So(err.Error(), ShouldEqual, core.Error(base.ErrAssertion, "expected [int] '2' not to be greater than [int] '1'").Error()) 81 }) 82 }) 83 84 Convey("When 1 and 1", func() { 85 Convey("It should not return an error", func() { 86 _, err := NotGt(context.Background(), values.NewInt(1), values.NewInt(1)) 87 88 So(err, ShouldBeNil) 89 }) 90 }) 91 92 Convey("When 1 and 2", func() { 93 Convey("It should not return an error", func() { 94 _, err := NotGt(context.Background(), values.NewInt(1), values.NewInt(2)) 95 96 So(err, ShouldBeNil) 97 }) 98 }) 99 }) 100 }