Implement controlled app launch (T-401)
This commit is contained in:
@@ -57,6 +57,41 @@ func TestSwitcherRemovesFailedInitialInstall(t *testing.T) {
|
||||
assertMissing(t, filepath.Join(root, transactionFileName))
|
||||
}
|
||||
|
||||
func TestSwitcherPreSwitchCheckPreventsUpdateAndCleansStaging(t *testing.T) {
|
||||
root := makeInstallRoot(t, "old", "new")
|
||||
checkErr := errors.New("target is running")
|
||||
switcher := NewSwitcherWithPreSwitchCheck(
|
||||
func(string) error { return nil },
|
||||
func() error {
|
||||
assertVersion(t, filepath.Join(root, "current"), "old")
|
||||
assertVersion(t, filepath.Join(root, "staging"), "new")
|
||||
return checkErr
|
||||
},
|
||||
)
|
||||
|
||||
err := switcher.Switch(root)
|
||||
if !errors.Is(err, checkErr) {
|
||||
t.Fatalf("Switch() error = %v, want %v", err, checkErr)
|
||||
}
|
||||
assertVersion(t, filepath.Join(root, "current"), "old")
|
||||
assertMissing(t, filepath.Join(root, "staging"))
|
||||
assertMissing(t, filepath.Join(root, "backup"))
|
||||
assertMissing(t, filepath.Join(root, transactionFileName))
|
||||
}
|
||||
|
||||
func TestSwitcherSkipsPreSwitchCheckForInitialInstall(t *testing.T) {
|
||||
root := makeInstallRoot(t, "", "new")
|
||||
switcher := NewSwitcherWithPreSwitchCheck(
|
||||
func(string) error { return nil },
|
||||
func() error { return errors.New("must not run") },
|
||||
)
|
||||
|
||||
if err := switcher.Switch(root); err != nil {
|
||||
t.Fatalf("Switch() error = %v", err)
|
||||
}
|
||||
assertVersion(t, filepath.Join(root, "current"), "new")
|
||||
}
|
||||
|
||||
func TestRecoverInterruptedSwitch(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
|
||||
Reference in New Issue
Block a user