Files
mesh-delivery/modules/mesh-delivery-sdk/trunk/trunk_test.go
T
jschoubben 3fffe7e2dd S2: the step runner checks only that an import set is sorted and each once
Nothing in a path or name tells a mesh package apart: mesh Go modules come from the Go
package registry, not the forge. The per-language form check and its settings go
(CheckGoImports, CheckNpmImports, DefaultNpmScope, AskSteps.ImportPrefix and ImportScope);
CheckImports judges every seat's set sorted and each once, and the indexer keeps of it the
packages a module of the module graph publishes.

Builds: design 47 H2 H-A-539 (withdraws H-A-534's form check and H-A-535's settings)
2026-11-23 11:26:47 +01:00

63 lines
2.6 KiB
Go

package trunk
import (
"testing"
)
func TestSameRepository(t *testing.T) { // 1281/AC1
const forge = "novox/mesh-catalog"
for _, c := range []struct {
a, b string
same bool
}{
// the clone URL as a build record carries it (mesh-controller.command builds, 2026-10-19 ~21:20 local)
{forge, "http://novox.internal:20000/novox/mesh-catalog.git", true},
{forge, "http://novox.internal:20000/novox/mesh-catalog", true},
{forge, "http://novox.internal:20000/novox/mesh-catalog.git/", true},
{"http://novox.internal:20000/novox/mesh-catalog.git/", forge, true},
{forge, "novox/mesh-catalog", true},
{forge, "Novox/Mesh-Catalog", true},
{forge, "http://novox.internal:20000/novox/mesh-catalog-x.git", false},
{forge, "novox/mesh-catalog-x", false},
{forge, "http://novox.internal:20000/other/mesh-catalog.git", false},
{forge, "other/mesh-catalog", false},
{forge, "http://novox.internal:20000/novox/mesh-media-catalog.git", false},
{forge, "", false},
{"", "", false},
} {
if got := SameRepository(c.a, c.b); got != c.same {
t.Errorf("SameRepository(%q, %q) = %v, want %v", c.a, c.b, got, c.same)
}
}
if got := RepositoryName("http://novox.internal:20000/novox/mesh-catalog.git"); got != "novox/mesh-catalog" {
t.Errorf("RepositoryName = %q", got)
}
}
func TestAnImportSetHoldsMeshPackagesSortedAndEachOnce(t *testing.T) {
// Design 47 H2 H-A-539: an import set is judged only sorted and each once, whatever forge, prefix or scope its entries name.
a, b := ForgeModulePrefix+"mesh-sdk/go", ForgeModulePrefix+"mesh-delivery/modules/mesh-delivery-sdk"
for name, good := range map[string][]string{"Go module paths": {b, a}, "another host": {"example.org/x/y", "github.com/x/y"},
"npm names": {"@novox/mesh-sdk", "@other/x", "left-pad"}, "none": nil} {
if err := CheckImports(good); err != nil {
t.Errorf("%s: %v is refused: %v", name, good, err)
}
}
for name, bad := range map[string][]string{"unsorted": {a, b}, "twice": {a, a}, "npm unsorted": {"@novox/mesh-sdk", "@novox/a"}} {
if CheckImports(bad) == nil {
t.Errorf("%s: %v is taken", name, bad)
}
}
}
// A repository keys the indexer's taken and the view's reach by its forge name, in lower case, from either spelling (ADR 0556).
func TestARepositoryIsKeyedByItsLowerCaseForgeName(t *testing.T) {
for in, want := range map[string]string{"novox/Mesh-SDK": "novox/mesh-sdk", "http://h:3000/novox/mesh-sdk.git": "novox/mesh-sdk",
"a/b.c": "a/b=2ec", "": "", "nope": "", "/x": ""} {
got, err := RepositoryKey(in)
if (want == "") != (err != nil) || got != want {
t.Errorf("RepositoryKey(%q) = %q, %v; want %q", in, got, err, want)
}
}
}