Both reads go in R4g with build-agent. A path a key names is never overwritten, and no fingerprint changes.
67 lines
3.9 KiB
Go
67 lines
3.9 KiB
Go
package index
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"git.novox.be/novox/mesh-sdk/go/delivery"
|
|
)
|
|
|
|
// The build records below are the live ones, as `mesh-controller.command builds` showed them on 2026-10-19 at about
|
|
// 21:20 local (the last 100 builds): id, state, module, repository (the clone URL, as the record names it), commit (the
|
|
// eight characters the listing shows), the time (the listing's local minute, as UTC), the source fingerprint, and the
|
|
// ref only where the listing shows "at main"; a build a delivery plan asked after a merge shows none, so the record
|
|
// carries none. No reading command shows a whole record, so two fields come from elsewhere: the path is the module's
|
|
// directory in the catalogue (a clone of mesh-catalog and mesh-media-catalog, origin/main at the same time), and the
|
|
// source-inputs are mailu's live inputs (build-1792391134620131370, captured in mesh-sdk go/delivery/fingerprint_test.go
|
|
// TestFingerprintLiveBuilds) with the module's name put in; the indexer reads only their bases, contexts and toolchains.
|
|
const (
|
|
liveTree = "cfc6fa8ff5fc1e220132e51ade653b9d3f387b3e"
|
|
liveInputsTail = `"Tree":"` + liveTree + `","Bases":["sha256:25f3cfeaceca14921366af4d1240b56457ef46273bdb508c7b0e8f469f6fd228"],"Contexts":null,` +
|
|
`"Toolchains":{"code":"typescript sha256:4b81682df5665c1f461d3f720a3a0fd7593f4aa71e4fc272dbfdc4bbd235b489 20125bd590041690"},"Unpinned":""}`
|
|
catalogURL = "http://novox.internal:20000/novox/mesh-catalog.git"
|
|
mediaCatalogURL = "http://novox.internal:20000/novox/mesh-media-catalog.git"
|
|
)
|
|
|
|
func liveRecord(id, module, repository, ref, commit, path, at, source string) [2]any {
|
|
raw := `{"id":"` + id + `","repository":"` + repository + `",`
|
|
if ref != "" {
|
|
raw += `"ref":"` + ref + `",`
|
|
}
|
|
raw += `"module":"` + module + `","commit":"` + commit + `","path":"` + path + `","at":"` + at + `","source-fingerprint":"` + source +
|
|
`","source-inputs":{"Module":"` + module + `",` + liveInputsTail + `}`
|
|
return [2]any{delivery.BuildKey(module, id), []byte(raw)}
|
|
}
|
|
|
|
func liveBuilds() [][2]any {
|
|
return [][2]any{
|
|
// a plan-asked build after a merge: no ref
|
|
liveRecord("build-1792417485811374131", "zsh", catalogURL, "", "e8c34487", "modules/zsh", "2026-10-19T13:57:00Z", "src1:7e600dde59f3d7f019af00741583304288883e7d3ed955f4c61da26474f3be63"),
|
|
liveRecord("build-1792435539606203626", "mesh-delivery", catalogURL, "", "9efdd87a", "modules/mesh-delivery", "2026-10-19T18:45:00Z", "src1:f79e2eedc2689cf6b3591ebfdb81ec65899131122fb2fe3dd9e384091d8a2a6d"),
|
|
// a build at main
|
|
liveRecord("build-1792417463192745880", "mailu", catalogURL, "main", "e8c34487", "modules/mailu", "2026-10-19T13:50:00Z", "src1:98d35b17d3a3295e3a0efed2b8c4316c9a9b32ec155f8343824654661b7383a2"),
|
|
// a module of another repository
|
|
liveRecord("build-1792417481951691634", "sonarr", mediaCatalogURL, "main", "197abb06", "modules/sonarr", "2026-10-19T13:57:00Z", "src1:0fff753b8c66aa8a8ac1f38d210cea9512a78a8592dd2475bfe6ade77ff21b61"),
|
|
}
|
|
}
|
|
|
|
func liveIndexer(t *testing.T) (*Indexer, *memStore) {
|
|
t.Helper()
|
|
ix, mods := modulesIndexer(t, liveBuilds()...)
|
|
return ix, mods
|
|
}
|
|
|
|
func TestTheLiveRecordsGiveTheDirectoryOfAModuleOfTheirRepository(t *testing.T) { // 1614 (I3: the records name directories, never list modules)
|
|
ix, _ := liveIndexer(t)
|
|
for module, want := range map[string]string{"zsh": "modules/zsh", "mesh-delivery": "modules/mesh-delivery", "mailu": "modules/mailu"} {
|
|
if got, ok := ix.Builds.PathOf(module, "novox/mesh-catalog"); !ok || got != want {
|
|
t.Errorf("PathOf(%s, novox/mesh-catalog) = %q, %v; want %q", module, got, ok, want)
|
|
}
|
|
}
|
|
if got, ok := ix.Builds.PathOf("sonarr", "novox/mesh-catalog"); ok {
|
|
t.Errorf("PathOf found %q for a module of mesh-media-catalog under mesh-catalog", got)
|
|
}
|
|
if got, ok := ix.Builds.PathOf("sonarr", "novox/mesh-media-catalog"); !ok || got != "modules/sonarr" {
|
|
t.Errorf("PathOf(sonarr, mesh-media-catalog) = %q, %v; want modules/sonarr", got, ok)
|
|
}
|
|
}
|