26 lines
1.1 KiB
Go
26 lines
1.1 KiB
Go
package inventory
|
|
|
|
import (
|
|
"strings"
|
|
"testing"
|
|
|
|
"github.com/novox/mesh-controller/internal/catalogue"
|
|
)
|
|
|
|
// The manifest the mesh holds carries each file's text (novox/hq ADR 0349 §2): one still naming a template — a
|
|
// build by a builder that predates templates, or a manifest handed over unbuilt — would compose a file with no
|
|
// text, and is refused by name.
|
|
func TestAManifestStillNamingATemplateIsNotRegistered(t *testing.T) {
|
|
inv := ForTest(t)
|
|
m := catalogue.Manifest{Module: "notifier", Version: "1", Resources: []map[string]any{
|
|
{"id": "conf", "type": "file", "path": "/etc/notifier.conf", "template": "files/notifier.conf"}}}
|
|
err := inv.RegisterModule(t.Context(), m, Source{})
|
|
if err == nil || !strings.Contains(err.Error(), "files/notifier.conf") {
|
|
t.Fatalf("a manifest naming a template was registered: %v", err)
|
|
}
|
|
m.Resources[0] = map[string]any{"id": "conf", "type": "file", "path": "/etc/notifier.conf", "content": "x"}
|
|
if err := inv.RegisterModule(t.Context(), m, Source{}); err != nil {
|
|
t.Fatalf("the same manifest with its text was refused: %v", err)
|
|
}
|
|
}
|