CMS Go module renamed from git.dev.alexdunmow.com/block/ninja to git.dev.alexdunmow.com/block/cms (along with the git remote rename on gitea). All import paths, string-literal rules, test fixtures, and doc references updated; (historical 'ninja-orchestrator' refs preserved). go mod tidy regenerated checksums. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
77 lines
2.3 KiB
Go
77 lines
2.3 KiB
Go
package main
|
|
|
|
import (
|
|
"path/filepath"
|
|
"testing"
|
|
)
|
|
|
|
func TestCheckStandalonePluginImportsFlagsBlockNinjaCMSImports(t *testing.T) {
|
|
root := t.TempDir()
|
|
writeTestFile(t, filepath.Join(root, "plugin.mod"), "[plugin]\nname = \"example\"\nversion = \"1.0.0\"\n", 0644)
|
|
writeTestFile(t, filepath.Join(root, "main.go"), `package example
|
|
|
|
import (
|
|
"git.dev.alexdunmow.com/block/core/plugin"
|
|
"git.dev.alexdunmow.com/block/cms/internal/helpers"
|
|
)
|
|
|
|
func Example() {
|
|
_ = plugin.PluginRegistration{}
|
|
_ = helpers.Slugify("x")
|
|
}
|
|
`, 0644)
|
|
|
|
violations := checkStandalonePluginImports(root)
|
|
if len(violations) != 1 {
|
|
t.Fatalf("checkStandalonePluginImports() returned %d violations, want 1: %#v", len(violations), violations)
|
|
}
|
|
if violations[0].importPath != "git.dev.alexdunmow.com/block/cms/internal/helpers" {
|
|
t.Fatalf("importPath = %q, want forbidden BlockNinja import", violations[0].importPath)
|
|
}
|
|
}
|
|
|
|
func TestCheckStandalonePluginImportsAllowsCoreSDKImports(t *testing.T) {
|
|
root := t.TempDir()
|
|
writeTestFile(t, filepath.Join(root, "plugin.mod"), "[plugin]\nname = \"example\"\nversion = \"1.0.0\"\n", 0644)
|
|
writeTestFile(t, filepath.Join(root, "main.go"), `package example
|
|
|
|
import "git.dev.alexdunmow.com/block/core/plugin"
|
|
|
|
func Example() {
|
|
_ = plugin.PluginRegistration{}
|
|
}
|
|
`, 0644)
|
|
|
|
violations := checkStandalonePluginImports(root)
|
|
if len(violations) != 0 {
|
|
t.Fatalf("checkStandalonePluginImports() returned %d violations, want 0: %#v", len(violations), violations)
|
|
}
|
|
}
|
|
|
|
func TestCheckStandalonePluginImportsFlagsBlockNinjaCMSImportsInTemplFiles(t *testing.T) {
|
|
root := t.TempDir()
|
|
writeTestFile(t, filepath.Join(root, "plugin.mod"), "[plugin]\nname = \"example\"\nversion = \"1.0.0\"\n", 0644)
|
|
writeTestFile(t, filepath.Join(root, "page.templ"), `package example
|
|
|
|
import (
|
|
"git.dev.alexdunmow.com/block/core/templates/bn"
|
|
"git.dev.alexdunmow.com/block/cms/internal/templates"
|
|
)
|
|
|
|
templ Page() {
|
|
<div></div>
|
|
}
|
|
`, 0644)
|
|
|
|
violations := checkStandalonePluginImports(root)
|
|
if len(violations) != 1 {
|
|
t.Fatalf("checkStandalonePluginImports() returned %d violations, want 1: %#v", len(violations), violations)
|
|
}
|
|
if violations[0].importPath != "git.dev.alexdunmow.com/block/cms/internal/templates" {
|
|
t.Fatalf("importPath = %q, want forbidden BlockNinja templ import", violations[0].importPath)
|
|
}
|
|
if violations[0].line != 5 {
|
|
t.Fatalf("line = %d, want 5", violations[0].line)
|
|
}
|
|
}
|