jx/internal/resource/common_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

36 lines
996 B
Go

// Copyright 2024 Matthew Rich <matthewrich.conf@gmail.com>. All rights reserved.
package resource
import (
"github.com/stretchr/testify/assert"
"testing"
"net/url"
"decl/internal/folio"
)
func TestNewCommon(t *testing.T) {
c := NewCommon(TypeName("foo"), false)
assert.NotNil(t, c)
}
func TestCommon(t *testing.T) {
expectedCommon := NewCommon(FileTypeName, false)
expectedCommon.resourceType = "file"
expectedCommon.parsedURI = &url.URL{ Scheme: "file", Path: "/tmp/foo"}
expectedCommon.Path = "/tmp/foo"
for _, v := range []struct{ uri folio.URI; expected *Common }{
{ uri: "file:///tmp/foo", expected: expectedCommon },
}{
c := NewCommon(FileTypeName, false)
c.resourceType = "file"
assert.Nil(t, c.SetParsedURI(v.uri.Parse()))
assert.Equal(t, v.expected.resourceType , c.resourceType)
assert.Equal(t, v.expected.Path, c.Path)
assert.Equal(t, v.expected.parsedURI.Scheme, c.parsedURI.Scheme)
assert.Equal(t, v.expected.parsedURI.Path, c.parsedURI.Path)
}
}