35 lines
930 B
Go
35 lines
930 B
Go
//go:build unix
|
|
|
|
package app
|
|
|
|
import (
|
|
"path/filepath"
|
|
"strings"
|
|
"testing"
|
|
|
|
"gitea.maximumdirect.net/eric/narratio/internal/config"
|
|
"golang.org/x/sys/unix"
|
|
)
|
|
|
|
func TestInspectStableInputsRejectsSpellCatalogFIFO(t *testing.T) {
|
|
root := t.TempDir()
|
|
sourcePath := filepath.Join(root, "spells.fifo")
|
|
if err := unix.Mkfifo(sourcePath, 0o644); err != nil {
|
|
t.Fatalf("Mkfifo() error = %v", err)
|
|
}
|
|
|
|
cfg := &config.Config{StableInputs: config.ResolvedStableInputs{
|
|
SpellCatalogFile: config.ResolvedInputFile{Path: sourcePath, ConfigPath: filepath.Join(root, "campaign.yml")},
|
|
}}
|
|
for _, check := range inspectStableInputs(cfg) {
|
|
if check.Name != "spell_catalog" {
|
|
continue
|
|
}
|
|
if check.Err == nil || !strings.Contains(check.Err.Error(), "not a regular file") {
|
|
t.Fatalf("spell catalog check = %#v, want regular-file rejection", check)
|
|
}
|
|
return
|
|
}
|
|
t.Fatal("spell catalog inspection result was not reported")
|
|
}
|