31 lines
686 B
Go
31 lines
686 B
Go
|
// Copyright 2024 Matthew Rich <matthewrich.conf@gmail.com>. All rights reserved.
|
||
|
|
||
|
package folio
|
||
|
|
||
|
import (
|
||
|
"github.com/stretchr/testify/assert"
|
||
|
"testing"
|
||
|
"fmt"
|
||
|
"decl/internal/data"
|
||
|
"decl/internal/mapper"
|
||
|
)
|
||
|
|
||
|
func TestResourceReference(t *testing.T) {
|
||
|
f := NewFooResource()
|
||
|
resourceMapper := mapper.New[string, data.Declaration]()
|
||
|
f.Name = TempDir
|
||
|
f.Size = 10
|
||
|
d := NewDeclaration()
|
||
|
d.Type = "foo"
|
||
|
d.Attributes = f
|
||
|
resourceMapper[d.URI()] = d
|
||
|
|
||
|
var foo ResourceReference = ResourceReference(fmt.Sprintf("foo://%s", TempDir))
|
||
|
u := foo.Parse()
|
||
|
assert.Equal(t, "foo", u.Scheme)
|
||
|
assert.True(t, foo.Exists())
|
||
|
|
||
|
fromRef := foo.Lookup(resourceMapper)
|
||
|
assert.NotNil(t, fromRef)
|
||
|
}
|