jx/internal/resource/common_test.go
Matthew Rich 10e854583f
All checks were successful
Lint / golangci-lint (push) Successful in 10m21s
Declarative Tests / test (push) Successful in 36s
fixes for http resource use of common
2024-09-28 05:04:15 +00: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"
)
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.Uri = "file:///tmp/foo"
expectedCommon.parsedURI = &url.URL{ Scheme: "file", Path: "/tmp/foo"}
expectedCommon.Path = "/tmp/foo"
for _, v := range []struct{ uri string; expected *Common }{
{ uri: "file:///tmp/foo", expected: expectedCommon },
}{
c := NewCommon(FileTypeName, false)
c.resourceType = "file"
assert.Nil(t, c.SetURI(v.uri))
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)
}
}