50 lines
1.0 KiB
Go
50 lines
1.0 KiB
Go
|
// Copyright 2024 Matthew Rich <matthewrich.conf@gmail.com>. All rights reserved.
|
||
|
|
||
|
package builtin
|
||
|
|
||
|
import (
|
||
|
"github.com/stretchr/testify/assert"
|
||
|
"log/slog"
|
||
|
"os"
|
||
|
"testing"
|
||
|
"decl/tests/tempdir"
|
||
|
"decl/internal/folio"
|
||
|
)
|
||
|
|
||
|
var TempDir tempdir.Path = "testbuiltin"
|
||
|
|
||
|
func TestMain(m *testing.M) {
|
||
|
err := TempDir.Create()
|
||
|
if err != nil || TempDir == "" {
|
||
|
slog.Error("Failed creating temp dir", "error", err)
|
||
|
}
|
||
|
|
||
|
rc := m.Run()
|
||
|
|
||
|
TempDir.Remove()
|
||
|
os.Exit(rc)
|
||
|
}
|
||
|
|
||
|
func TestBuiltInLoad(t *testing.T) {
|
||
|
docs, err := Load("file://documents/facter.jx.yaml")
|
||
|
assert.Nil(t, err)
|
||
|
assert.Greater(t, len(docs), 0)
|
||
|
}
|
||
|
|
||
|
func TestBuiltInDocuments(t *testing.T) {
|
||
|
docs, err := BuiltInDocuments()
|
||
|
assert.Nil(t, err)
|
||
|
config, ok := folio.DocumentRegistry.GetDocument("file://documents/facter.jx.yaml")
|
||
|
|
||
|
assert.True(t, ok)
|
||
|
assert.Greater(t, len(docs), 0)
|
||
|
|
||
|
slog.Info("TestBuiltInDocuments()", "docuemnt", config)
|
||
|
|
||
|
assert.True(t, config.HasConfig("facts"))
|
||
|
c := config.GetConfig("facts")
|
||
|
v, e := c.GetValue("virtual")
|
||
|
assert.Nil(t, e)
|
||
|
assert.Equal(t, "physical", v)
|
||
|
}
|