Skip to content

Commit

Permalink
set store in kots for testing
Browse files Browse the repository at this point in the history
  • Loading branch information
Siva Manivannan committed Dec 15, 2023
1 parent 11beaf6 commit f1c319c
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
12 changes: 12 additions & 0 deletions integration/replicated/pull_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,26 @@ import (
"path"
"testing"

"github.com/golang/mock/gomock"
"github.com/mholt/archiver/v3"
"github.com/replicatedhq/kots/integration/util"
"github.com/replicatedhq/kots/pkg/pull"
"github.com/replicatedhq/kots/pkg/store"
mock_store "github.com/replicatedhq/kots/pkg/store/mock"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)

func Test_PullReplicated(t *testing.T) {
ctrl := gomock.NewController(t)
defer ctrl.Finish()

mockStore := mock_store.NewMockStore(ctrl)
store.SetStore(mockStore)
defer store.SetStore(nil)

mockStore.EXPECT().ListInstalledApps().MaxTimes(1)

namespace := "test_ns"

testDirs, err := ioutil.ReadDir("tests")
Expand Down
9 changes: 9 additions & 0 deletions pkg/store/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,12 @@ func GetStore() Store {
func storeFromEnv() Store {
return kotsstore.StoreFromEnv()
}

func SetStore(s Store) {
if s == nil {
hasStore = false
globalStore = nil
}
hasStore = true
globalStore = s
}

0 comments on commit f1c319c

Please sign in to comment.