github.com/MontFerret/ferret@v0.18.0/pkg/stdlib/path/is_abs_test.go (about)

     1  package path_test
     2  
     3  import (
     4  	"context"
     5  	"testing"
     6  
     7  	. "github.com/smartystreets/goconvey/convey"
     8  
     9  	"github.com/MontFerret/ferret/pkg/runtime/values"
    10  	"github.com/MontFerret/ferret/pkg/stdlib/path"
    11  )
    12  
    13  func TestIsAbs(t *testing.T) {
    14  	Convey("When arg is not passed", t, func() {
    15  		Convey("It should return an error", func() {
    16  			var err error
    17  			_, err = path.IsAbs(context.Background())
    18  
    19  			So(err, ShouldBeError)
    20  		})
    21  	})
    22  
    23  	Convey("Wrong argument", t, func() {
    24  		var err error
    25  		_, err = path.IsAbs(context.Background(), values.NewInt(0))
    26  
    27  		So(err, ShouldBeError)
    28  	})
    29  
    30  	Convey("IsAbs('/ferret/bin/ferret') should return true", t, func() {
    31  		out, _ := path.IsAbs(
    32  			context.Background(),
    33  			values.NewString("/ferret/bin/ferret"),
    34  		)
    35  
    36  		So(out, ShouldEqual, values.True)
    37  	})
    38  
    39  	Convey("IsAbs('..') should return false", t, func() {
    40  		out, _ := path.IsAbs(
    41  			context.Background(),
    42  			values.NewString(".."),
    43  		)
    44  
    45  		So(out, ShouldEqual, values.False)
    46  	})
    47  }