40 lines
890 B
Go
40 lines
890 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()
|
|
assert.Equal(t, "file", u.Scheme)
|
|
assert.True(t, file.Exists())
|
|
file = URI(fmt.Sprintf("0file:_/%s", TempDir))
|
|
u = file.Parse()
|
|
assert.Nil(t, u)
|
|
}
|
|
|
|
func TestURISetURL(t *testing.T) {
|
|
var file URI = URI(fmt.Sprintf("file://%s", TempDir))
|
|
u := file.Parse()
|
|
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)
|
|
|
|
}
|
|
|