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>
105 lines
3.0 KiB
Go
105 lines
3.0 KiB
Go
package main
|
|
|
|
import (
|
|
"path/filepath"
|
|
"strings"
|
|
"testing"
|
|
)
|
|
|
|
func TestCheckCMSCoreSDKGoModFlagsLocalBlockCoreReplace(t *testing.T) {
|
|
root := t.TempDir()
|
|
writeTestFile(t, filepath.Join(root, "go.mod"), `module git.dev.alexdunmow.com/block/cms
|
|
|
|
go 1.26.2
|
|
|
|
require git.dev.alexdunmow.com/block/core v0.5.0
|
|
|
|
replace git.dev.alexdunmow.com/block/core => ../core
|
|
`, 0644)
|
|
|
|
violations := checkCMSCoreSDKGoMod(root)
|
|
if len(violations) != 1 {
|
|
t.Fatalf("checkCMSCoreSDKGoMod() returned %d violations, want 1: %#v", len(violations), violations)
|
|
}
|
|
if violations[0].rule != "no-local-block-core-replace" {
|
|
t.Fatalf("rule = %q, want no-local-block-core-replace", violations[0].rule)
|
|
}
|
|
if violations[0].line != 7 {
|
|
t.Fatalf("line = %d, want 7", violations[0].line)
|
|
}
|
|
}
|
|
|
|
func TestCheckCMSCoreSDKGoModAllowsPublishedBlockCoreRequire(t *testing.T) {
|
|
root := t.TempDir()
|
|
writeTestFile(t, filepath.Join(root, "go.mod"), `module git.dev.alexdunmow.com/block/cms
|
|
|
|
go 1.26.2
|
|
|
|
require git.dev.alexdunmow.com/block/core v0.5.0
|
|
`, 0644)
|
|
|
|
violations := checkCMSCoreSDKGoMod(root)
|
|
if len(violations) != 0 {
|
|
t.Fatalf("checkCMSCoreSDKGoMod() returned %d violations, want 0: %#v", len(violations), violations)
|
|
}
|
|
}
|
|
|
|
func TestCheckStandalonePluginGoModFlagsReplaceDirectives(t *testing.T) {
|
|
root := t.TempDir()
|
|
writeTestFile(t, filepath.Join(root, "go.mod"), `module example.com/plugin
|
|
|
|
go 1.26.2
|
|
|
|
require git.dev.alexdunmow.com/block/core v0.2.1
|
|
|
|
replace git.dev.alexdunmow.com/block/core => ../block-core
|
|
`, 0644)
|
|
|
|
violations := checkStandalonePluginGoMod(root, "v0.2.1")
|
|
if len(violations) != 1 {
|
|
t.Fatalf("checkStandalonePluginGoMod() returned %d violations, want 1: %#v", len(violations), violations)
|
|
}
|
|
if violations[0].rule != "no-replace-directives" {
|
|
t.Fatalf("rule = %q, want no-replace-directives", violations[0].rule)
|
|
}
|
|
if violations[0].line != 7 {
|
|
t.Fatalf("line = %d, want 7", violations[0].line)
|
|
}
|
|
}
|
|
|
|
func TestCheckStandalonePluginGoModFlagsOutdatedSDKVersion(t *testing.T) {
|
|
root := t.TempDir()
|
|
writeTestFile(t, filepath.Join(root, "go.mod"), `module example.com/plugin
|
|
|
|
go 1.26.2
|
|
|
|
require git.dev.alexdunmow.com/block/core v0.2.0
|
|
`, 0644)
|
|
|
|
violations := checkStandalonePluginGoMod(root, "v0.2.1")
|
|
if len(violations) != 1 {
|
|
t.Fatalf("checkStandalonePluginGoMod() returned %d violations, want 1: %#v", len(violations), violations)
|
|
}
|
|
if violations[0].rule != "block-core-version-mismatch" {
|
|
t.Fatalf("rule = %q, want block-core-version-mismatch", violations[0].rule)
|
|
}
|
|
if !strings.Contains(violations[0].detail, "want v0.2.1") {
|
|
t.Fatalf("detail = %q, want target version", violations[0].detail)
|
|
}
|
|
}
|
|
|
|
func TestCheckStandalonePluginGoModAllowsMatchingSDKVersionWithoutReplace(t *testing.T) {
|
|
root := t.TempDir()
|
|
writeTestFile(t, filepath.Join(root, "go.mod"), `module example.com/plugin
|
|
|
|
go 1.26.2
|
|
|
|
require git.dev.alexdunmow.com/block/core v0.2.1
|
|
`, 0644)
|
|
|
|
violations := checkStandalonePluginGoMod(root, "v0.2.1")
|
|
if len(violations) != 0 {
|
|
t.Fatalf("checkStandalonePluginGoMod() returned %d violations, want 0: %#v", len(violations), violations)
|
|
}
|
|
}
|