jx/internal/folio/uri_test.go

40 lines
903 B
Go
Raw Normal View History

2024-08-15 15:12:42 +00:00
// 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()
2024-08-15 15:12:42 +00:00
assert.Equal(t, "file", u.Scheme)
assert.True(t, file.Exists())
2024-08-18 01:19:56 +00:00
file = URI(fmt.Sprintf("0file:_/%s", TempDir))
x := file.Parse()
assert.Nil(t, x)
2024-08-15 15:12:42 +00:00
}
2024-08-18 01:19:56 +00:00
func TestURISetURL(t *testing.T) {
var file URI = URI(fmt.Sprintf("file://%s", TempDir))
u := file.Parse().URL()
2024-08-18 01:19:56 +00:00
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)
}