package main import ( "testing" "git.novox.be/novox/mesh-sdk/go/catalogue" ) // Defends novox/hq ADR 0111: a build source is on the git seat, or it is external. func forgeHolding(port any) catalogue.World { return catalogue.World{ Held: []catalogue.Held{{Claim: "git", Scope: catalogue.ScopeMesh, Node: "anchor", Module: "gitea"}}, Offered: map[string][]catalogue.Provider{"git": { // A second forge that does not hold the seat, so taking the first one found would be wrong. {Node: "archive", At: "archive.internal", Module: "gitea-mirror", Serves: map[string]any{"scheme": "http", "port": float64(3000)}}, {Node: "anchor", At: "anchor.internal", Module: "gitea", Serves: map[string]any{"scheme": "http", "port": port}}, }}, } } func TestAnAddressGivenAsAPathOnTheForgeIsRefused(t *testing.T) { for _, bad := range []string{ "https://github.com/someone/something.git", "git@anchor:novox/mesh-catalog.git", "/srv/git/mesh-catalog", "", } { if err := onASeat(bad); err == nil { t.Errorf("--self accepted %q as a path on the forge", bad) } } if err := onASeat("novox/mesh-catalog"); err != nil { t.Errorf("a path on the forge was refused: %v", err) } } func TestASourceOnTheSeatReadsAsAPathNotAnAddress(t *testing.T) { s := buildSource{Repository: "novox/mesh-catalog", Seat: "git"} if got := s.String(); got != "novox/mesh-catalog on the git seat" { t.Fatalf("read as %q", got) } }