Skip to content

Commit

Permalink
Added test for invalidate
Browse files Browse the repository at this point in the history
  • Loading branch information
ilijamt committed Sep 1, 2023
1 parent 2b2aaff commit 989a80f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
2 changes: 1 addition & 1 deletion backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ type Backend struct {
}

func (b *Backend) periodicFunc(ctx context.Context, request *logical.Request) error {
b.Logger().Debug("Periodic action executed")
b.Logger().Debug("Periodic action executing")
return b.rotateConfigToken(ctx, request)

Check warning on line 85 in backend.go

View check run for this annotation

Codecov / codecov/patch

backend.go#L83-L85

Added lines #L83 - L85 were not covered by tests
}

Expand Down
13 changes: 12 additions & 1 deletion backend_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"github.com/stretchr/testify/require"
g "github.com/xanzy/go-gitlab"
"golang.org/x/exp/slices"
"reflect"
"sync"
"testing"
"time"
Expand Down Expand Up @@ -95,8 +96,18 @@ func getBackend() (*gitlab.Backend, logical.Storage, error) {

func TestBackend(t *testing.T) {
var err error
_, _, err = getBackend()
var b *gitlab.Backend
b, _, err = getBackend()
require.NoError(t, err)
require.NotNil(t, b)
fv := reflect.ValueOf(b).Elem().FieldByName("client")
require.True(t, fv.IsNil())
b.SetClient(&inMemoryClient{})
require.False(t, fv.IsNil())
b.Invalidate(context.Background(), gitlab.PathConfigStorage)
require.True(t, fv.IsNil())
b.SetClient(&inMemoryClient{})
require.False(t, fv.IsNil())
}

func countErrByName(err *multierror.Error) map[string]int {
Expand Down

0 comments on commit 989a80f

Please sign in to comment.