github.com/MontFerret/ferret@v0.18.0/pkg/stdlib/testing/gte_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 TestGte(t *t.T) { 16 Gte := base.NewPositiveAssertion(testing.Gte) 17 18 Convey("When arg is not passed", t, func() { 19 Convey("It should return an error", func() { 20 _, err := Gte(context.Background()) 21 22 So(err, ShouldBeError) 23 24 _, err = Gte(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 := Gte(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 or equal to [int] '2'").Error()) 37 }) 38 }) 39 40 Convey("When 1 and 1", func() { 41 Convey("It should not return an error", func() { 42 _, err := Gte(context.Background(), values.NewInt(1), values.NewInt(1)) 43 44 So(err, ShouldBeNil) 45 }) 46 }) 47 48 Convey("When 2 and 1", func() { 49 Convey("It should not return an error", func() { 50 _, err := Gte(context.Background(), values.NewInt(2), values.NewInt(1)) 51 52 So(err, ShouldBeNil) 53 }) 54 }) 55 }) 56 } 57 58 func TestNotGte(t *t.T) { 59 NotGte := base.NewNegativeAssertion(testing.Gte) 60 61 Convey("When arg is not passed", t, func() { 62 Convey("It should return an error", func() { 63 _, err := NotGte(context.Background()) 64 65 So(err, ShouldBeError) 66 67 _, err = NotGte(context.Background(), values.NewInt(1)) 68 69 So(err, ShouldBeError) 70 }) 71 }) 72 73 Convey("When args are numbers", t, func() { 74 Convey("When 1 and 2", func() { 75 Convey("It should not return an error", func() { 76 _, err := NotGte(context.Background(), values.NewInt(1), values.NewInt(2)) 77 78 So(err, ShouldBeNil) 79 }) 80 }) 81 82 Convey("When 1 and 1", func() { 83 Convey("It should return an error", func() { 84 _, err := NotGte(context.Background(), values.NewInt(1), values.NewInt(1)) 85 86 So(err, ShouldBeError) 87 So(err.Error(), ShouldEqual, core.Error(base.ErrAssertion, "expected [int] '1' not to be greater than or equal to [int] '1'").Error()) 88 }) 89 }) 90 91 Convey("When 2 and 1", func() { 92 Convey("It should return an error", func() { 93 _, err := NotGte(context.Background(), values.NewInt(2), values.NewInt(1)) 94 95 So(err, ShouldBeError) 96 So(err.Error(), ShouldEqual, core.Error(base.ErrAssertion, "expected [int] '2' not to be greater than or equal to [int] '1'").Error()) 97 }) 98 }) 99 }) 100 }