package main import ( "errors" "testing" "github.com/novox/mesh-controller/internal/link" ) // **A merge whose plan could not be saved is held, never taken** (novox/hq ADR 0407 decision 3, issue 1092): the merge is // carried until its plan is saved, and the bus acknowledges the announcement only when the controller answers without // ErrTryAgain (link.Server.sourceMoved), so a failed save of any kind must answer it. func TestAFailureToSaveAMergesPlanIsHeldAndNotTaken(t *testing.T) { cause := errors.New("the plan for novox/mesh-catalog is not written: the plan was written by somebody else since it was read") held := unsaved(cause) if !errors.Is(held, link.ErrTryAgain) || !errors.Is(held, cause) { t.Fatalf("a failed save answers %v", held) } if unsaved(nil) != nil { t.Fatal("a save that worked answers an error") } // Not the same as notNow, which holds a merge only for a store that is away. if errors.Is(notNow(cause), link.ErrTryAgain) { t.Fatal("notNow holds every failure; the premise of this test is gone") } }