mirror of
https://github.com/TecharoHQ/anubis.git
synced 2026-04-12 03:28:45 +00:00
fix(data): add services folder to embedded filesystem
Also includes a regression test to ensure this does not happen again. Assisted-By: GLM 4.6 via Claude Code
This commit is contained in:
@@ -3,6 +3,6 @@ package data
|
|||||||
import "embed"
|
import "embed"
|
||||||
|
|
||||||
var (
|
var (
|
||||||
//go:embed botPolicies.yaml all:apps all:bots all:clients all:common all:crawlers all:meta
|
//go:embed botPolicies.yaml all:apps all:bots all:clients all:common all:crawlers all:meta all:services
|
||||||
BotPolicies embed.FS
|
BotPolicies embed.FS
|
||||||
)
|
)
|
||||||
|
|||||||
38
data/embed_test.go
Normal file
38
data/embed_test.go
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
package data
|
||||||
|
|
||||||
|
import (
|
||||||
|
"path/filepath"
|
||||||
|
"strings"
|
||||||
|
"testing"
|
||||||
|
)
|
||||||
|
|
||||||
|
// TestBotPoliciesEmbed ensures all YAML files in the directory tree
|
||||||
|
// are accessible in the embedded BotPolicies filesystem.
|
||||||
|
func TestBotPoliciesEmbed(t *testing.T) {
|
||||||
|
yamlFiles, err := filepath.Glob("./**/*.yaml")
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("Failed to glob YAML files: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(yamlFiles) == 0 {
|
||||||
|
t.Fatal("No YAML files found in directory tree")
|
||||||
|
}
|
||||||
|
|
||||||
|
t.Logf("Found %d YAML files to verify", len(yamlFiles))
|
||||||
|
|
||||||
|
for _, filePath := range yamlFiles {
|
||||||
|
embeddedPath := strings.TrimPrefix(filePath, "./")
|
||||||
|
|
||||||
|
t.Run(embeddedPath, func(t *testing.T) {
|
||||||
|
content, err := BotPolicies.ReadFile(embeddedPath)
|
||||||
|
if err != nil {
|
||||||
|
t.Errorf("Failed to read %s from embedded filesystem: %v", embeddedPath, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(content) == 0 {
|
||||||
|
t.Errorf("File %s exists in embedded filesystem but is empty", embeddedPath)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user