From f1c319cfc7742d08e31bc9e87b4196a6d627b322 Mon Sep 17 00:00:00 2001 From: Siva Manivannan Date: Fri, 15 Dec 2023 11:53:54 -0600 Subject: [PATCH] set store in kots for testing --- integration/replicated/pull_test.go | 12 ++++++++++++ pkg/store/store.go | 9 +++++++++ 2 files changed, 21 insertions(+) diff --git a/integration/replicated/pull_test.go b/integration/replicated/pull_test.go index ee8d45a146..625d562099 100644 --- a/integration/replicated/pull_test.go +++ b/integration/replicated/pull_test.go @@ -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") diff --git a/pkg/store/store.go b/pkg/store/store.go index 2937e140aa..6b33204202 100644 --- a/pkg/store/store.go +++ b/pkg/store/store.go @@ -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 +}