Skip to content

Commit

Permalink
Set up store for tests
Browse files Browse the repository at this point in the history
  • Loading branch information
RebeccaMahany committed Jun 25, 2024
1 parent e171fc7 commit 86b7f35
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 0 deletions.
5 changes: 5 additions & 0 deletions pkg/osquery/interactive/interactive_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ import (

"github.com/kolide/kit/fsutil"
"github.com/kolide/kit/ulid"
"github.com/kolide/launcher/ee/agent/storage"
storageci "github.com/kolide/launcher/ee/agent/storage/ci"
"github.com/kolide/launcher/ee/agent/types/mocks"
"github.com/kolide/launcher/pkg/log/multislogger"
"github.com/kolide/launcher/pkg/packaging"
Expand Down Expand Up @@ -97,6 +99,9 @@ func TestProc(t *testing.T) {
mockSack.On("OsqueryFlags").Return(tt.osqueryFlags)
mockSack.On("Slogger").Return(multislogger.NewNopLogger())
mockSack.On("RootDirectory").Maybe().Return("whatever_the_root_launcher_dir_is")
store, err := storageci.NewStore(t, multislogger.NewNopLogger(), storage.AtcConfigStore.String())
require.NoError(t, err)
mockSack.On("AtcConfigStore").Return(store)

proc, _, err := StartProcess(mockSack, rootDir)

Expand Down
8 changes: 8 additions & 0 deletions pkg/osquery/runtime/runtime_posix_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import (
"testing"
"time"

"github.com/kolide/launcher/ee/agent/storage"
storageci "github.com/kolide/launcher/ee/agent/storage/ci"
typesMocks "github.com/kolide/launcher/ee/agent/types/mocks"
"github.com/kolide/launcher/pkg/log/multislogger"
"github.com/kolide/launcher/pkg/threadsafebuffer"
Expand Down Expand Up @@ -51,6 +53,9 @@ func TestOsquerySlowStart(t *testing.T) {
slogger := multislogger.New(slog.NewJSONHandler(&logBytes, &slog.HandlerOptions{Level: slog.LevelDebug}))
k.On("Slogger").Return(slogger.Logger)
k.On("LatestOsquerydPath", mock.Anything).Return(testOsqueryBinaryDirectory)
store, err := storageci.NewStore(t, multislogger.NewNopLogger(), storage.AtcConfigStore.String())
require.NoError(t, err)
k.On("AtcConfigStore").Return(store)

runner := New(
k,
Expand Down Expand Up @@ -95,6 +100,9 @@ func TestExtensionSocketPath(t *testing.T) {
k.On("RegisterChangeObserver", mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything)
k.On("Slogger").Return(multislogger.NewNopLogger())
k.On("LatestOsquerydPath", mock.Anything).Return(testOsqueryBinaryDirectory)
store, err := storageci.NewStore(t, multislogger.NewNopLogger(), storage.AtcConfigStore.String())
require.NoError(t, err)
k.On("AtcConfigStore").Return(store)

extensionSocketPath := filepath.Join(rootDirectory, "sock")
runner := New(
Expand Down
18 changes: 18 additions & 0 deletions pkg/osquery/runtime/runtime_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,9 @@ func TestWithOsqueryFlags(t *testing.T) {
k.On("RegisterChangeObserver", mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything)
k.On("Slogger").Return(multislogger.NewNopLogger())
k.On("LatestOsquerydPath", mock.Anything).Return(testOsqueryBinaryDirectory)
store, err := storageci.NewStore(t, multislogger.NewNopLogger(), storage.AtcConfigStore.String())
require.NoError(t, err)
k.On("AtcConfigStore").Return(store)

runner := New(
k,
Expand Down Expand Up @@ -368,6 +371,9 @@ func TestFlagsChanged(t *testing.T) {
k.On("RegisterChangeObserver", mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything)
k.On("Slogger").Return(multislogger.NewNopLogger())
k.On("LatestOsquerydPath", mock.Anything).Return(testOsqueryBinaryDirectory)
store, err := storageci.NewStore(t, multislogger.NewNopLogger(), storage.AtcConfigStore.String())
require.NoError(t, err)
k.On("AtcConfigStore").Return(store)

// Start the runner
runner := New(
Expand Down Expand Up @@ -461,6 +467,9 @@ func TestSimplePath(t *testing.T) {
k.On("RegisterChangeObserver", mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything)
k.On("Slogger").Return(multislogger.NewNopLogger())
k.On("LatestOsquerydPath", mock.Anything).Return(testOsqueryBinaryDirectory)
store, err := storageci.NewStore(t, multislogger.NewNopLogger(), storage.AtcConfigStore.String())
require.NoError(t, err)
k.On("AtcConfigStore").Return(store)

runner := New(
k,
Expand Down Expand Up @@ -489,6 +498,9 @@ func TestMultipleShutdowns(t *testing.T) {
k.On("RegisterChangeObserver", mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything)
k.On("Slogger").Return(multislogger.NewNopLogger())
k.On("LatestOsquerydPath", mock.Anything).Return(testOsqueryBinaryDirectory)
store, err := storageci.NewStore(t, multislogger.NewNopLogger(), storage.AtcConfigStore.String())
require.NoError(t, err)
k.On("AtcConfigStore").Return(store)

runner := New(
k,
Expand Down Expand Up @@ -516,6 +528,9 @@ func TestOsqueryDies(t *testing.T) {
k.On("RegisterChangeObserver", mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything)
k.On("Slogger").Return(multislogger.NewNopLogger())
k.On("LatestOsquerydPath", mock.Anything).Return(testOsqueryBinaryDirectory)
store, err := storageci.NewStore(t, multislogger.NewNopLogger(), storage.AtcConfigStore.String())
require.NoError(t, err)
k.On("AtcConfigStore").Return(store)

runner := New(
k,
Expand Down Expand Up @@ -610,6 +625,9 @@ func setupOsqueryInstanceForTests(t *testing.T) (runner *Runner, teardown func()
k.On("RegisterChangeObserver", mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything).Maybe()
k.On("Slogger").Return(multislogger.NewNopLogger())
k.On("LatestOsquerydPath", mock.Anything).Return(testOsqueryBinaryDirectory)
store, err := storageci.NewStore(t, multislogger.NewNopLogger(), storage.AtcConfigStore.String())
require.NoError(t, err)
k.On("AtcConfigStore").Return(store)

runner = New(
k,
Expand Down

0 comments on commit 86b7f35

Please sign in to comment.