ac8ea72025
gates / gates (push) Successful in 25s
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0159rPz1ZhFKsS53msqPYxtS
27 lines
1.1 KiB
Go
27 lines
1.1 KiB
Go
package selfupdate
|
|
|
|
import "testing"
|
|
|
|
// decision 56 (R-745): the controller's previous image comes from the swap record only when that record is a
|
|
// SUCCESS that ended on the running version. COMPANION RED-PROOF: drop the Status check → the failed-swap row fails.
|
|
func TestRecordedPrevious(t *testing.T) {
|
|
ok := &UpdateState{Status: "success", PreviousVersion: "0.284.2", PreviousImage: "r:0.284.2", TargetVersion: "0.285.0"}
|
|
cases := []struct {
|
|
name string
|
|
st *UpdateState
|
|
running string
|
|
want string
|
|
}{
|
|
{"success onto the running version", ok, "0.285.0", "r:0.284.2"},
|
|
{"no record", nil, "0.285.0", ""},
|
|
{"the record is about another version", ok, "0.286.0", ""},
|
|
{"a failed swap (rolled back: the box runs the 'previous')", &UpdateState{Status: "failed", PreviousVersion: "0.284.2", PreviousImage: "r:0.284.2", TargetVersion: "0.285.0"}, "0.285.0", ""},
|
|
{"pending", &UpdateState{Status: "pending", PreviousImage: "r:0.284.2", TargetVersion: "0.285.0"}, "0.285.0", ""},
|
|
}
|
|
for _, c := range cases {
|
|
if got := c.st.RecordedPrevious(c.running); got != c.want {
|
|
t.Errorf("%s: got %q, want %q", c.name, got, c.want)
|
|
}
|
|
}
|
|
}
|