Skip to content

Commit

Permalink
initial unit test
Browse files Browse the repository at this point in the history
Signed-off-by: Manik2708 <mehtamanik96@gmail.com>
  • Loading branch information
Manik2708 committed Jan 25, 2025
1 parent fa11ef6 commit bd19543
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions plugin/storage/es/ilm/createpolicy_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// Copyright (c) 2025 The Jaeger Authors.
// SPDX-License-Identifier: Apache-2.0

package ilm

import (
"testing"

"github.com/stretchr/testify/mock"
"github.com/stretchr/testify/require"

"github.com/jaegertracing/jaeger/pkg/es"
"github.com/jaegertracing/jaeger/pkg/es/mocks"
)

func mockTestingClient(mockFxn func(cl *mocks.Client)) es.Client {
c := &mocks.Client{}
mockFxn(c)
return c
}

func mockIlmPolicyExists(exists bool) es.Client {
return mockTestingClient(func(cl *mocks.Client) {
cl.On("IlmPolicyExists", mock.Anything, DefaultIlmPolicy).Return(exists, nil)
})
}

func TestCreatePolicyIfNotExists(t *testing.T) {
t.Run("IlmPolicyExists", func(t *testing.T) {
cl := mockIlmPolicyExists(true)
err := CreatePolicyIfNotExists(cl, false, 7)
require.NoError(t, err)
})
}

0 comments on commit bd19543

Please sign in to comment.