Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
juliaElastic committed Nov 21, 2023
1 parent 8182bab commit 37106b0
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
1 change: 1 addition & 0 deletions internal/pkg/api/handleAck_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -602,6 +602,7 @@ func TestInvalidateAPIKeysRemoteOutput(t *testing.T) {

bulker.AssertExpectations(t)
remoteBulker.AssertExpectations(t)
remoteBulker2.AssertExpectations(t)
}

func TestAckHandleUpgrade(t *testing.T) {
Expand Down
11 changes: 6 additions & 5 deletions internal/pkg/policy/policy_output_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -305,10 +305,10 @@ func TestPolicyRemoteESOutputPrepareNoRole(t *testing.T) {
Role: nil,
}
outputBulker := ftesting.NewMockBulk()
bulker.On("CreateAndGetBulker", mock.Anything, mock.Anything, mock.Anything, mock.Anything).Return(outputBulker, false).Once()
bulker.On("CreateAndGetBulker", mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything).Return(outputBulker, false).Once()

err := po.Prepare(context.Background(), logger, bulker, &model.Agent{}, map[string]map[string]interface{}{})
require.NotNil(t, err, "expected prepare to error")
require.Error(t, err, "expected prepare to error")
bulker.AssertExpectations(t)
}

Expand All @@ -330,7 +330,7 @@ func TestPolicyRemoteESOutputPrepare(t *testing.T) {
}

outputBulker := ftesting.NewMockBulk()
bulker.On("CreateAndGetBulker", mock.Anything, mock.Anything, mock.Anything, mock.Anything).Return(outputBulker, false).Once()
bulker.On("CreateAndGetBulker", mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything).Return(outputBulker, false).Once()

policyMap := map[string]map[string]interface{}{
"test output": map[string]interface{}{
Expand Down Expand Up @@ -391,7 +391,7 @@ func TestPolicyRemoteESOutputPrepare(t *testing.T) {
Return(nil).Once()

outputBulker := ftesting.NewMockBulk()
bulker.On("CreateAndGetBulker", mock.Anything, mock.Anything, mock.Anything, mock.Anything).Return(outputBulker, false).Once()
bulker.On("CreateAndGetBulker", mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything).Return(outputBulker, false).Once()

outputBulker.
On("APIKeyRead", mock.Anything, mock.Anything, mock.Anything).
Expand Down Expand Up @@ -461,7 +461,8 @@ func TestPolicyRemoteESOutputPrepare(t *testing.T) {
outputBulker.On("APIKeyCreate",
mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything).
Return(&apiKey, nil).Once()
bulker.On("CreateAndGetBulker", mock.Anything, mock.Anything, mock.Anything, mock.Anything).Return(outputBulker, false).Once()
bulker.On("CreateAndGetBulker", mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything).Return(outputBulker, false).Once()
bulker.On("GetRemoteOutputErrorMap").Return(make(map[string]string))

output := Output{
Type: OutputTypeRemoteElasticsearch,
Expand Down
2 changes: 1 addition & 1 deletion internal/pkg/server/remote_es_output_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ func Checkin(t *testing.T, ctx context.Context, srv *tserver, agentID, key strin
defaultOutput, ok := outputs["default"].(map[string]interface{})
require.True(t, ok, "expected default to be map")
defaultAPIKey := defaultOutput["api_key"]
require.False(t, remoteAPIKey == defaultAPIKey, "expected remote api key to be different than default")
require.NotEqual(t, remoteAPIKey, defaultAPIKey, "expected remote api key to be different than default")

}

Expand Down

0 comments on commit 37106b0

Please sign in to comment.