github.com/MontFerret/ferret@v0.18.0/pkg/stdlib/path/dir_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 TestDir(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.Dir(context.Background())
    18  
    19  			So(err, ShouldBeError)
    20  		})
    21  	})
    22  
    23  	Convey("Wrong argument", t, func() {
    24  		var err error
    25  		_, err = path.Dir(context.Background(), values.NewInt(0))
    26  
    27  		So(err, ShouldBeError)
    28  	})
    29  
    30  	Convey("Dir('pkg/path/dir.go') should return 'pkg/path'", t, func() {
    31  		out, _ := path.Dir(
    32  			context.Background(),
    33  			values.NewString("pkg/path/dir.go"),
    34  		)
    35  
    36  		So(out, ShouldEqual, "pkg/path")
    37  	})
    38  }