2024-03-20 19:25:25 +00:00
|
|
|
// Copyright 2024 Matthew Rich <matthewrich.conf@gmail.com>. All rights reserved.
|
2024-03-20 16:15:27 +00:00
|
|
|
package resource
|
|
|
|
|
|
|
|
import (
|
|
|
|
"os"
|
2024-03-20 19:25:25 +00:00
|
|
|
_ "path/filepath"
|
|
|
|
_ "fmt"
|
2024-03-20 16:15:27 +00:00
|
|
|
"log"
|
|
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
)
|
|
|
|
|
|
|
|
var TempDir string
|
|
|
|
|
|
|
|
func TestMain(m *testing.M) {
|
|
|
|
var err error
|
|
|
|
TempDir, err = os.MkdirTemp("", "testresourcefile")
|
|
|
|
if err != nil || TempDir == "" {
|
|
|
|
log.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
rc := m.Run()
|
|
|
|
|
2024-03-20 19:25:25 +00:00
|
|
|
os.RemoveAll(TempDir)
|
2024-03-20 16:15:27 +00:00
|
|
|
os.Exit(rc)
|
|
|
|
}
|
|
|
|
|
2024-03-20 19:25:25 +00:00
|
|
|
func TestNewResource(t *testing.T) {
|
|
|
|
resourceUri := "file://foo"
|
|
|
|
testFile := NewResource(resourceUri)
|
|
|
|
assert.NotNil(t, testFile)
|
2024-03-20 16:15:27 +00:00
|
|
|
|
2024-03-20 19:25:25 +00:00
|
|
|
assert.Equal(t, "foo", testFile.(*File).Path)
|
2024-03-20 16:15:27 +00:00
|
|
|
}
|