Skip to content

Commit

Permalink
rename global var to match agent reset test pattern
Browse files Browse the repository at this point in the history
  • Loading branch information
zackattack01 committed Dec 23, 2024
1 parent 5bd3710 commit 9f6e0cf
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 16 deletions.
8 changes: 4 additions & 4 deletions pkg/osquery/runtime/osqueryinstance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func TestCreateOsqueryCommand(t *testing.T) {
extensionAutoloadPath: "/foo/bar/osquery.autoload",
}

osquerydPath := testOsqueryBinaryPath
osquerydPath := testOsqueryBinary

k := typesMocks.NewKnapsack(t)
k.On("WatchdogEnabled").Return(true)
Expand Down Expand Up @@ -86,7 +86,7 @@ func TestCreateOsqueryCommandWithFlags(t *testing.T) {
i := newInstance(types.DefaultRegistrationID, k, mockServiceClient())

cmd, err := i.createOsquerydCommand(
testOsqueryBinaryPath,
testOsqueryBinary,
&osqueryFilePaths{},
)
require.NoError(t, err)
Expand Down Expand Up @@ -120,7 +120,7 @@ func TestCreateOsqueryCommand_SetsEnabledWatchdogSettingsAppropriately(t *testin
i := newInstance(types.DefaultRegistrationID, k, mockServiceClient())

cmd, err := i.createOsquerydCommand(
testOsqueryBinaryPath,
testOsqueryBinary,
&osqueryFilePaths{},
)
require.NoError(t, err)
Expand Down Expand Up @@ -170,7 +170,7 @@ func TestCreateOsqueryCommand_SetsDisabledWatchdogSettingsAppropriately(t *testi
i := newInstance(types.DefaultRegistrationID, k, mockServiceClient())

cmd, err := i.createOsquerydCommand(
testOsqueryBinaryPath,
testOsqueryBinary,
&osqueryFilePaths{},
)
require.NoError(t, err)
Expand Down
2 changes: 1 addition & 1 deletion pkg/osquery/runtime/osqueryinstance_windows_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import (
func TestCreateOsqueryCommandEnvVars(t *testing.T) {
t.Parallel()

osquerydPath := testOsqueryBinaryPath
osquerydPath := testOsqueryBinary

k := typesMocks.NewKnapsack(t)
k.On("WatchdogEnabled").Return(true)
Expand Down
22 changes: 11 additions & 11 deletions pkg/osquery/runtime/runtime_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ import (
"github.com/stretchr/testify/require"
)

var testOsqueryBinaryPath string
var testOsqueryBinary string

// TestMain overrides the default test main function. This allows us to share setup/teardown.
func TestMain(m *testing.M) {
Expand All @@ -67,9 +67,9 @@ func TestMain(m *testing.M) {
os.Exit(1) //nolint:forbidigo // Fine to use os.Exit in tests
}

testOsqueryBinaryPath = filepath.Join(binDirectory, "osqueryd")
testOsqueryBinary = filepath.Join(binDirectory, "osqueryd")
if runtime.GOOS == "windows" {
testOsqueryBinaryPath += ".exe"
testOsqueryBinary += ".exe"
}

thrift.ServerConnectivityCheckInterval = 100 * time.Millisecond
Expand Down Expand Up @@ -170,7 +170,7 @@ func TestWithOsqueryFlags(t *testing.T) {
k.On("WatchdogEnabled").Return(false)
k.On("RegisterChangeObserver", mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything)
k.On("Slogger").Return(slogger)
k.On("LatestOsquerydPath", mock.Anything).Return(testOsqueryBinaryPath)
k.On("LatestOsquerydPath", mock.Anything).Return(testOsqueryBinary)
k.On("RootDirectory").Return(rootDirectory).Maybe()
k.On("OsqueryFlags").Return([]string{"verbose=false"})
k.On("OsqueryVerbose").Return(false)
Expand Down Expand Up @@ -204,7 +204,7 @@ func TestFlagsChanged(t *testing.T) {
k.On("WatchdogDelaySec").Return(120)
k.On("RegisterChangeObserver", mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything)
k.On("Slogger").Return(slogger)
k.On("LatestOsquerydPath", mock.Anything).Return(testOsqueryBinaryPath)
k.On("LatestOsquerydPath", mock.Anything).Return(testOsqueryBinary)
k.On("RootDirectory").Return(rootDirectory).Maybe()
k.On("OsqueryFlags").Return([]string{"verbose=false"})
k.On("OsqueryVerbose").Return(false)
Expand Down Expand Up @@ -335,7 +335,7 @@ func TestSimplePath(t *testing.T) {
k.On("WatchdogEnabled").Return(false)
k.On("RegisterChangeObserver", mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything)
k.On("Slogger").Return(slogger)
k.On("LatestOsquerydPath", mock.Anything).Return(testOsqueryBinaryPath)
k.On("LatestOsquerydPath", mock.Anything).Return(testOsqueryBinary)
k.On("RootDirectory").Return(rootDirectory).Maybe()
k.On("OsqueryFlags").Return([]string{})
k.On("OsqueryVerbose").Return(true)
Expand Down Expand Up @@ -371,7 +371,7 @@ func TestMultipleInstances(t *testing.T) {
k.On("WatchdogEnabled").Return(false)
k.On("RegisterChangeObserver", mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything)
k.On("Slogger").Return(slogger)
k.On("LatestOsquerydPath", mock.Anything).Return(testOsqueryBinaryPath)
k.On("LatestOsquerydPath", mock.Anything).Return(testOsqueryBinary)
k.On("RootDirectory").Return(rootDirectory).Maybe()
k.On("OsqueryFlags").Return([]string{})
k.On("OsqueryVerbose").Return(true)
Expand Down Expand Up @@ -430,7 +430,7 @@ func TestRunnerHandlesImmediateShutdownWithMultipleInstances(t *testing.T) {
k.On("WatchdogEnabled").Return(false)
k.On("RegisterChangeObserver", mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything)
k.On("Slogger").Return(slogger)
k.On("LatestOsquerydPath", mock.Anything).Return(testOsqueryBinaryPath)
k.On("LatestOsquerydPath", mock.Anything).Return(testOsqueryBinary)
k.On("RootDirectory").Return(rootDirectory).Maybe()
k.On("OsqueryFlags").Return([]string{})
k.On("OsqueryVerbose").Return(true)
Expand Down Expand Up @@ -481,7 +481,7 @@ func TestMultipleShutdowns(t *testing.T) {
k.On("WatchdogEnabled").Return(false)
k.On("RegisterChangeObserver", mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything)
k.On("Slogger").Return(slogger)
k.On("LatestOsquerydPath", mock.Anything).Return(testOsqueryBinaryPath)
k.On("LatestOsquerydPath", mock.Anything).Return(testOsqueryBinary)
k.On("RootDirectory").Return(rootDirectory).Maybe()
k.On("OsqueryFlags").Return([]string{})
k.On("OsqueryVerbose").Return(true)
Expand Down Expand Up @@ -513,7 +513,7 @@ func TestOsqueryDies(t *testing.T) {
k.On("WatchdogEnabled").Return(false)
k.On("RegisterChangeObserver", mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything)
k.On("Slogger").Return(slogger)
k.On("LatestOsquerydPath", mock.Anything).Return(testOsqueryBinaryPath)
k.On("LatestOsquerydPath", mock.Anything).Return(testOsqueryBinary)
k.On("RootDirectory").Return(rootDirectory)
k.On("OsqueryFlags").Return([]string{})
k.On("OsqueryVerbose").Return(true)
Expand Down Expand Up @@ -615,7 +615,7 @@ func setupOsqueryInstanceForTests(t *testing.T) (runner *Runner, logBytes *threa
k.On("WatchdogDelaySec").Return(120)
k.On("RegisterChangeObserver", mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything).Maybe()
k.On("Slogger").Return(slogger)
k.On("LatestOsquerydPath", mock.Anything).Return(testOsqueryBinaryPath)
k.On("LatestOsquerydPath", mock.Anything).Return(testOsqueryBinary)
k.On("RootDirectory").Return(rootDirectory).Maybe()
k.On("OsqueryFlags").Return([]string{}).Maybe()
k.On("OsqueryVerbose").Return(true).Maybe()
Expand Down

0 comments on commit 9f6e0cf

Please sign in to comment.