1
0
mirror of https://github.com/MontFerret/ferret.git synced 2025-01-22 03:39:08 +02:00
ferret/pkg/stdlib/path/ext_test.go
Aleksandr Yakimenko ed8e43e4c6
Add Path functions (#505)
* Add Path functions

* Add unit tests
2020-05-12 22:19:41 -04:00

38 lines
749 B
Go

package path_test
import (
"context"
"testing"
"github.com/MontFerret/ferret/pkg/runtime/values"
"github.com/MontFerret/ferret/pkg/stdlib/path"
. "github.com/smartystreets/goconvey/convey"
)
func TestExt(t *testing.T) {
Convey("When arg is not passed", t, func() {
Convey("It should return an error", func() {
var err error
_, err = path.Ext(context.Background())
So(err, ShouldBeError)
})
})
Convey("Wrong argument", t, func() {
var err error
_, err = path.Ext(context.Background(), values.NewInt(0))
So(err, ShouldBeError)
})
Convey("Ext('dir/main.go') should return '.go'", t, func() {
out, _ := path.Ext(
context.Background(),
values.NewString("dir/main.go"),
)
So(out, ShouldEqual, ".go")
})
}