56 lines
2.2 KiB
Go
56 lines
2.2 KiB
Go
//go:build integration
|
|
|
|
package main
|
|
|
|
import (
|
|
"strings"
|
|
"testing"
|
|
|
|
"github.com/novox/mesh-controller/internal/catalogue"
|
|
"github.com/novox/mesh-controller/internal/inventory"
|
|
)
|
|
|
|
// A merge into a branch other than the trunk starts no delivery (novox/hq ADR 0401 clause 3, issue 889): a
|
|
// module recorded with no ref follows the trunk, main, and no other branch.
|
|
func TestAMergeIntoANonTrunkBranchStartsNoDelivery(t *testing.T) {
|
|
for ref, name := range map[string]string{"": "noref", "main": "mainref"} {
|
|
t.Run(name, func(t *testing.T) {
|
|
open := windowed(t)
|
|
asksWithPaths(t)
|
|
if err := open.inventory.RegisterModule(t.Context(), catalogue.Manifest{Module: "free", Version: "1"},
|
|
inventory.Source{Repository: "novox/free", Seat: "git", Ref: ref, BuiltFrom: "c0", Head: "c0"}); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
feature := lone(repoMerge("free", "f1", t0))
|
|
feature.Base = "feat/57-config-and-provisioning"
|
|
said := captured(t, func() error { return (following{open: open}).hearMerge(t.Context(), feature, t0) })
|
|
if ws, bs := walks(t, open); len(ws) != 0 || len(bs) != 0 {
|
|
t.Fatalf("a merge into a feature branch: %d walk(s), %d batch(es)", len(ws), len(bs))
|
|
}
|
|
if !strings.Contains(said, feature.Base) || !strings.Contains(said, "starts no delivery") {
|
|
t.Fatalf("the merge was not said to start no delivery: %q", said)
|
|
}
|
|
hear(t, open, lone(repoMerge("free", "m1", t0)), t0)
|
|
if ws, bs := walks(t, open); len(ws)+len(bs) != 1 {
|
|
t.Fatalf("a merge into main: %d walk(s), %d batch(es)", len(ws), len(bs))
|
|
}
|
|
})
|
|
}
|
|
}
|
|
|
|
// A module recorded with an explicit branch keeps following that branch (the lead's settlement of issue 977 Q5).
|
|
func TestAModuleRecordedWithABranchStillFollowsIt(t *testing.T) {
|
|
open := windowed(t)
|
|
asksWithPaths(t)
|
|
if err := open.inventory.RegisterModule(t.Context(), catalogue.Manifest{Module: "pinned", Version: "1"},
|
|
inventory.Source{Repository: "novox/pinned", Seat: "git", Ref: "feat/x", BuiltFrom: "c0", Head: "c0"}); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
m := lone(repoMerge("pinned", "p1", t0))
|
|
m.Base = "feat/x"
|
|
hear(t, open, m, t0)
|
|
if ws, bs := walks(t, open); len(ws)+len(bs) != 1 {
|
|
t.Fatalf("a merge into the branch a module follows: %d walk(s), %d batch(es)", len(ws), len(bs))
|
|
}
|
|
}
|