github.com/MontFerret/ferret@v0.18.0/pkg/stdlib/path/separate_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 TestSeparate(t *testing.T) {
    14  	Convey("When arg is not passed", t, func() {
    15  		Convey("It should return an error", func() {
    16  			_, err := path.Separate(context.Background())
    17  
    18  			So(err, ShouldBeError)
    19  		})
    20  	})
    21  
    22  	Convey("Wrong argument", t, func() {
    23  		var err error
    24  		_, err = path.Separate(context.Background(), values.NewInt(0))
    25  
    26  		So(err, ShouldBeError)
    27  	})
    28  
    29  	Convey("Separate('http://site.com/logo.png') should return ['http://site.com/', 'logo.png']", t, func() {
    30  		out, _ := path.Separate(
    31  			context.Background(),
    32  			values.NewString("http://site.com/logo.png"),
    33  		)
    34  
    35  		expected := values.NewArrayWith(values.NewString("http://site.com/"), values.NewString("logo.png"))
    36  		So(out, ShouldResemble, expected)
    37  	})
    38  }