mirror of
https://github.com/MontFerret/ferret.git
synced 2025-01-22 03:39:08 +02:00
ed8e43e4c6
* Add Path functions * Add unit tests
38 lines
749 B
Go
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")
|
|
})
|
|
}
|