This repository has been archived on 2026-11-02. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
mesh-controller/cmd/mesh-controller/paths_source_test.go

41 lines
1.9 KiB
Go

package main
import (
"testing"
"git.novox.be/novox/mesh-sdk/go/catalogue"
"github.com/novox/mesh-controller/internal/inventory"
)
// B1 (ADR 0499 §1, §5; issue 1758): a module whose every artifact names the paths it is built from is read from those
// paths and its manifest alone. mesh-sdk's TypeScript package at its repository's root: a change to its go/ touches no
// module, one to its src/ or its package.json touches it. A module with an artifact naming no paths reads its directory.
func TestAModuleNamingItsPathsIsReadFromThemAlone(t *testing.T) {
m, err := catalogue.ParseManifest([]byte(`{"module":"mesh-sdk","version":"1","build":{"artifacts":[{"name":"lib",
"kind":"package","language":"typescript","paths":["src","package.json","package-lock.json","tsconfig.json"]}]},
"resources":[]}`))
if err != nil {
t.Fatal(err)
}
own := pathsBuildSource(m, "")
read := inventory.WithBuildSources(nil, []inventory.BuildSource{{Paths: own}})
e := inventory.Entry{Manifest: m, Source: inventory.Source{Repository: "novox/mesh-sdk", Path: ""}}
for file, reads := range map[string]bool{
"go/delivery/builder.go": false, "go/go.mod": false, "README.md": false,
"src/index.ts": true, "src/deep/x.ts": true, "package.json": true, "module.json": true,
} {
if got := readsFile(e, read, file); got != reads {
t.Errorf("%s: read %v, want %v", file, got, reads)
}
}
// In a module's directory, the paths are under it.
if got := pathsBuildSource(m, "modules/sdk"); got[0] != "modules/sdk/module.json" || got[1] != "modules/sdk/src/**" {
t.Errorf("paths under a directory: %v", got)
}
// An artifact naming no paths: the whole directory, as before.
m.Build.Artifacts = append(m.Build.Artifacts, catalogue.Artifact{Name: "files", Kind: "archive", From: "files"})
if got := pathsBuildSource(m, ""); got != nil {
t.Errorf("a module with an artifact naming no paths is narrowed to %v", got)
}
}