jx/internal/resource/resource_test.go
2024-03-20 12:25:25 -07:00

35 lines
629 B
Go

// Copyright 2024 Matthew Rich <matthewrich.conf@gmail.com>. All rights reserved.
package resource
import (
"os"
_ "path/filepath"
_ "fmt"
"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()
os.RemoveAll(TempDir)
os.Exit(rc)
}
func TestNewResource(t *testing.T) {
resourceUri := "file://foo"
testFile := NewResource(resourceUri)
assert.NotNil(t, testFile)
assert.Equal(t, "foo", testFile.(*File).Path)
}