github.com/MontFerret/ferret@v0.18.0/pkg/stdlib/testing/none_test.go (about)

     1  package testing_test
     2  
     3  import (
     4  	"context"
     5  	t "testing"
     6  
     7  	"github.com/MontFerret/ferret/pkg/runtime/values"
     8  	"github.com/MontFerret/ferret/pkg/stdlib/testing/base"
     9  
    10  	. "github.com/smartystreets/goconvey/convey"
    11  
    12  	"github.com/MontFerret/ferret/pkg/stdlib/testing"
    13  )
    14  
    15  func TestNone(t *t.T) {
    16  	None := base.NewPositiveAssertion(testing.None)
    17  
    18  	Convey("When arg is not passed", t, func() {
    19  		Convey("It should return an error", func() {
    20  			_, err := None(context.Background())
    21  
    22  			So(err, ShouldBeError)
    23  		})
    24  	})
    25  
    26  	Convey("When arg is not none", t, func() {
    27  		Convey("It should return an error", func() {
    28  			_, err := None(context.Background(), values.NewString("true"))
    29  
    30  			So(err, ShouldBeError)
    31  			So(err.Error(), ShouldEqual, base.ErrAssertion.Error()+": expected [string] 'true' to be [none] 'none'")
    32  		})
    33  	})
    34  
    35  	Convey("When arg is none", t, func() {
    36  		Convey("It should not return an error", func() {
    37  			_, err := None(context.Background(), values.None)
    38  
    39  			So(err, ShouldBeNil)
    40  		})
    41  	})
    42  }
    43  
    44  func TestNotNone(t *t.T) {
    45  	NotNone := base.NewNegativeAssertion(testing.None)
    46  
    47  	Convey("When arg is not passed", t, func() {
    48  		Convey("It should return an error", func() {
    49  			_, err := NotNone(context.Background())
    50  
    51  			So(err, ShouldBeError)
    52  		})
    53  	})
    54  
    55  	Convey("When arg is none", t, func() {
    56  		Convey("It should return an error", func() {
    57  			_, err := NotNone(context.Background(), values.None)
    58  
    59  			So(err, ShouldBeError)
    60  			So(err.Error(), ShouldEqual, base.ErrAssertion.Error()+": expected [none] 'none' not to be [none] 'none'")
    61  		})
    62  	})
    63  
    64  	Convey("When arg is not none", t, func() {
    65  		Convey("It should return an error", func() {
    66  			_, err := NotNone(context.Background(), values.False)
    67  
    68  			So(err, ShouldBeNil)
    69  		})
    70  	})
    71  }