github.com/MontFerret/ferret@v0.18.0/pkg/stdlib/testing/false_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/values" 10 "github.com/MontFerret/ferret/pkg/stdlib/testing" 11 "github.com/MontFerret/ferret/pkg/stdlib/testing/base" 12 ) 13 14 func TestFalse(t *t.T) { 15 False := base.NewPositiveAssertion(testing.False) 16 17 Convey("When arg is not passed", t, func() { 18 Convey("It should return an error", func() { 19 _, err := False(context.Background()) 20 21 So(err, ShouldBeError) 22 }) 23 }) 24 25 Convey("When arg is not boolean", t, func() { 26 Convey("It should return an error", func() { 27 _, err := False(context.Background(), values.NewString("false")) 28 29 So(err, ShouldBeError) 30 So(err.Error(), ShouldEqual, base.ErrAssertion.Error()+": expected [string] 'false' to be [boolean] 'false'") 31 }) 32 }) 33 34 Convey("When arg is true", t, func() { 35 Convey("It should return an error", func() { 36 _, err := False(context.Background(), values.True) 37 38 So(err, ShouldBeError) 39 So(err.Error(), ShouldEqual, base.ErrAssertion.Error()+": expected [boolean] 'true' to be [boolean] 'false'") 40 }) 41 }) 42 43 Convey("When arg is false", t, func() { 44 Convey("It should not return an error", func() { 45 _, err := False(context.Background(), values.False) 46 47 So(err, ShouldBeNil) 48 }) 49 }) 50 } 51 52 func TestNotFalse(t *t.T) { 53 NotFalse := base.NewNegativeAssertion(testing.False) 54 55 Convey("When arg is not passed", t, func() { 56 Convey("It should return an error", func() { 57 _, err := NotFalse(context.Background()) 58 59 So(err, ShouldBeError) 60 }) 61 }) 62 63 Convey("When arg is not boolean", t, func() { 64 Convey("It should not return an error", func() { 65 _, err := NotFalse(context.Background(), values.NewString("false")) 66 67 So(err, ShouldBeNil) 68 }) 69 }) 70 71 Convey("When arg is false", t, func() { 72 Convey("It should return an error", func() { 73 _, err := NotFalse(context.Background(), values.False) 74 75 So(err, ShouldBeError) 76 So(err.Error(), ShouldEqual, base.ErrAssertion.Error()+": expected [boolean] 'false' not to be [boolean] 'false'") 77 }) 78 }) 79 80 Convey("When arg is true", t, func() { 81 Convey("It should return an error", func() { 82 _, err := NotFalse(context.Background(), values.True) 83 84 So(err, ShouldBeNil) 85 }) 86 }) 87 }