// Copyright 2024 Matthew Rich . All rights reserved. package builtin import ( "github.com/stretchr/testify/assert" "log/slog" "os" "testing" "decl/tests/tempdir" "decl/internal/folio" "errors" ) 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") if ! errors.Is(err, os.ErrNotExist) { assert.Nil(t, err) assert.Greater(t, len(docs), 0) } } func TestBuiltInDocuments(t *testing.T) { docs, err := BuiltInDocuments() assert.Greater(t, len(docs), 0) if ! errors.Is(err, os.ErrNotExist) { assert.Nil(t, err) config, ok := folio.DocumentRegistry.GetDocument("file://documents/facter.jx.yaml") assert.True(t, ok) 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) } systemConfig, systemExists := folio.DocumentRegistry.GetDocument("file://documents/system.jx.yaml") assert.True(t, systemExists) assert.True(t, systemConfig.HasConfig("system")) }