jx/internal/folio/uri_test.go
Matthew Rich 8feb7b8d56
Some checks failed
Lint / golangci-lint (push) Failing after 10m1s
Declarative Tests / test (push) Failing after 14s
add support of import search paths [doublejynx/jx#7]
2024-10-16 10:26:42 -07:00

40 lines
903 B
Go

// Copyright 2024 Matthew Rich <matthewrich.conf@gmail.com>. All rights reserved.
package folio
import (
"github.com/stretchr/testify/assert"
"testing"
"fmt"
)
func TestURI(t *testing.T) {
var file URI = URI(fmt.Sprintf("file://%s", TempDir))
u := file.Parse().URL()
assert.Equal(t, "file", u.Scheme)
assert.True(t, file.Exists())
file = URI(fmt.Sprintf("0file:_/%s", TempDir))
x := file.Parse()
assert.Nil(t, x)
}
func TestURISetURL(t *testing.T) {
var file URI = URI(fmt.Sprintf("file://%s", TempDir))
u := file.Parse().URL()
var fileFromURL URI
fileFromURL.SetURL(u)
assert.Equal(t, fileFromURL, file)
exttype, ext := file.Extension()
assert.Equal(t, "", exttype)
assert.Equal(t, "", ext)
}
func TestURINewResource(t *testing.T) {
var file URI = URI(fmt.Sprintf("foo://%s", TempDir))
resource, err := file.NewResource(nil)
assert.Nil(t, err)
assert.NotNil(t, resource)
}