Skip to content

Commit

Permalink
fix install tests
Browse files Browse the repository at this point in the history
  • Loading branch information
BinaryFissionGames committed Jul 29, 2022
1 parent 1896ace commit e52785c
Showing 1 changed file with 0 additions and 35 deletions.
35 changes: 0 additions & 35 deletions updater/internal/install/install_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ func TestInstallArtifacts(t *testing.T) {
err = os.WriteFile(outDirManager, []byte("# The original manager file"), 0600)
require.NoError(t, err)

svc.On("Stop").Once().Return(nil)
svc.On("Update").Once().Return(nil)
svc.On("Start").Once().Return(nil)

Expand Down Expand Up @@ -96,31 +95,13 @@ func TestInstallArtifacts(t *testing.T) {
copyNestedTestTxtAction.FileCreated = true

require.Equal(t, []action.RollbackableAction{
action.NewServiceStopAction(svc),
copyNestedTestTxtAction,
copyTestTxtAction,
action.NewServiceUpdateAction(installer.logger, installer.installDir),
action.NewServiceStartAction(svc),
}, actions)
})

t.Run("Stop fails", func(t *testing.T) {
outDir := t.TempDir()
svc := mocks.NewService(t)
rb := rb_mocks.NewActionAppender(t)
installer := &Installer{
latestDir: filepath.Join("testdata", "example-install"),
installDir: outDir,
svc: svc,
logger: zaptest.NewLogger(t),
}

svc.On("Stop").Once().Return(errors.New("stop failed"))

err := installer.Install(rb)
require.ErrorContains(t, err, "failed to stop service")
})

t.Run("Update fails", func(t *testing.T) {
outDir := t.TempDir()
svc := mocks.NewService(t)
Expand All @@ -132,7 +113,6 @@ func TestInstallArtifacts(t *testing.T) {
logger: zaptest.NewLogger(t),
}

svc.On("Stop").Once().Return(nil)
svc.On("Update").Once().Return(errors.New("uninstall failed"))

actions := []action.RollbackableAction{}
Expand Down Expand Up @@ -162,7 +142,6 @@ func TestInstallArtifacts(t *testing.T) {
copyNestedTestTxtAction.FileCreated = true

require.Equal(t, []action.RollbackableAction{
action.NewServiceStopAction(svc),
copyNestedTestTxtAction,
copyTestTxtAction,
}, actions)
Expand All @@ -179,7 +158,6 @@ func TestInstallArtifacts(t *testing.T) {
logger: zaptest.NewLogger(t),
}

svc.On("Stop").Once().Return(nil)
svc.On("Update").Once().Return(nil)
svc.On("Start").Once().Return(errors.New("start failed"))

Expand Down Expand Up @@ -211,7 +189,6 @@ func TestInstallArtifacts(t *testing.T) {
copyNestedTestTxtAction.FileCreated = true

require.Equal(t, []action.RollbackableAction{
action.NewServiceStopAction(svc),
copyNestedTestTxtAction,
copyTestTxtAction,
action.NewServiceUpdateAction(installer.logger, installer.installDir),
Expand All @@ -229,20 +206,8 @@ func TestInstallArtifacts(t *testing.T) {
logger: zaptest.NewLogger(t),
}

svc.On("Stop").Once().Return(nil)

actions := []action.RollbackableAction{}
rb.On("AppendAction", mock.Anything).Run(func(args mock.Arguments) {
action := args.Get(0).(action.RollbackableAction)
actions = append(actions, action)
})

err := installer.Install(rb)
require.ErrorContains(t, err, "failed to install new files")

require.Equal(t, []action.RollbackableAction{
action.NewServiceStopAction(svc),
}, actions)
})
}

Expand Down

0 comments on commit e52785c

Please sign in to comment.