Skip to content

Commit

Permalink
Upgrade service integration test (#4757)
Browse files Browse the repository at this point in the history
* upgrade service integration test
  • Loading branch information
sgalsaleh authored Jul 12, 2024
1 parent 066752b commit b7eebc1
Show file tree
Hide file tree
Showing 4 changed files with 446 additions and 5 deletions.
14 changes: 14 additions & 0 deletions pkg/handlers/handlers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@ package handlers_test

import (
"fmt"
"log"
"net/http"
"net/http/httptest"
"os"
"testing"
"time"

Expand All @@ -24,6 +26,18 @@ import (
"github.com/stretchr/testify/require"
)

func TestMain(m *testing.M) {
behavior := os.Getenv("MOCK_BEHAVIOR")
switch behavior {
case "":
os.Exit(m.Run())
case "upgrade-service-cmd":
mockUpgradeServiceCmd()
default:
log.Fatalf("unknown behavior %q", behavior)
}
}

var HandlerPolicyTests = map[string][]HandlerPolicyTest{
// Installation
"UploadNewLicense": {
Expand Down
10 changes: 5 additions & 5 deletions pkg/handlers/upgrade_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ func startUpgradeService(a *apptypes.App, r StartUpgradeServiceRequest) error {
finishedChan <- finalError
}()

params, err := getUpgradeServiceParams(a, r)
params, err := GetUpgradeServiceParams(store.GetStore(), a, r)
if err != nil {
return err
}
Expand All @@ -185,18 +185,18 @@ func startUpgradeService(a *apptypes.App, r StartUpgradeServiceRequest) error {
return nil
}

func getUpgradeServiceParams(a *apptypes.App, r StartUpgradeServiceRequest) (*upgradeservicetypes.UpgradeServiceParams, error) {
registrySettings, err := store.GetStore().GetRegistryDetailsForApp(a.ID)
func GetUpgradeServiceParams(s store.Store, a *apptypes.App, r StartUpgradeServiceRequest) (*upgradeservicetypes.UpgradeServiceParams, error) {
registrySettings, err := s.GetRegistryDetailsForApp(a.ID)
if err != nil {
return nil, errors.Wrap(err, "failed to get registry details for app")
}

baseArchive, baseSequence, err := store.GetStore().GetAppVersionBaseArchive(a.ID, r.VersionLabel)
baseArchive, baseSequence, err := s.GetAppVersionBaseArchive(a.ID, r.VersionLabel)
if err != nil {
return nil, errors.Wrap(err, "failed to get app version base archive")
}

nextSequence, err := store.GetStore().GetNextAppSequence(a.ID)
nextSequence, err := s.GetNextAppSequence(a.ID)
if err != nil {
return nil, errors.Wrap(err, "failed to get next app sequence")
}
Expand Down
Loading

0 comments on commit b7eebc1

Please sign in to comment.