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