Skip to content

Commit

Permalink
refactor(tests): add missing build constraints and update mock for ha…
Browse files Browse the repository at this point in the history
…ndler-cache
  • Loading branch information
Th3Shadowbroker committed Feb 20, 2025
1 parent b9125a2 commit ecff49f
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 26 deletions.
59 changes: 33 additions & 26 deletions internal/test/handler_cache_mock.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
//
// SPDX-License-Identifier: Apache-2.0

//go:build testing

package test

import (
Expand All @@ -15,67 +17,72 @@ type MockHandlerCache struct {
mock.Mock
}

func (f *MockHandlerCache) Get(ctx context.Context, key interface{}) (interface{}, error) {
args := f.Called(ctx, key)
func (c *MockHandlerCache) Get(ctx context.Context, key interface{}) (interface{}, error) {
args := c.Called(ctx, key)
return args.Get(0), args.Error(1)
}

func (f *MockHandlerCache) Set(ctx context.Context, key interface{}, value interface{}) error {
args := f.Called(ctx, key, value)
func (c *MockHandlerCache) Set(ctx context.Context, key interface{}, value interface{}) error {
args := c.Called(ctx, key, value)
return args.Error(0)
}

func (f *MockHandlerCache) TryLockWithTimeout(ctx context.Context, key interface{}, timeout time.Duration) (bool, error) {
args := f.Called(ctx, key, timeout)
func (c *MockHandlerCache) TryLockWithTimeout(ctx context.Context, key interface{}, timeout time.Duration) (bool, error) {
args := c.Called(ctx, key, timeout)
return args.Bool(0), args.Error(1)
}

func (c *MockHandlerCache) TryLockWithLease(ctx context.Context, key interface{}, duration time.Duration) (bool, error) {
args := c.Called(ctx, key, duration)
return args.Bool(0), args.Error(1)
}

func (d *MockHandlerCache) TryLockWithLeaseAndTimeout(ctx context.Context, key interface{}, lease time.Duration, timeout time.Duration) (bool, error) {
args := d.Called(ctx, key, timeout)
func (c *MockHandlerCache) TryLockWithLeaseAndTimeout(ctx context.Context, key interface{}, lease time.Duration, timeout time.Duration) (bool, error) {
args := c.Called(ctx, key, timeout)
return args.Bool(0), args.Error(1)
}

func (f *MockHandlerCache) GetEntrySet(ctx context.Context) ([]types.Entry, error) {
args := f.Called(ctx)
func (c *MockHandlerCache) GetEntrySet(ctx context.Context) ([]types.Entry, error) {
args := c.Called(ctx)
return args.Get(0).([]types.Entry), args.Error(1)
}

func (f *MockHandlerCache) NewLockContext(ctx context.Context) context.Context {
args := f.Called(ctx)
func (c *MockHandlerCache) NewLockContext(ctx context.Context) context.Context {
args := c.Called(ctx)
return args.Get(0).(context.Context)
}

func (f *MockHandlerCache) Delete(ctx context.Context, key interface{}) error {
args := f.Called(ctx, key)
func (c *MockHandlerCache) Delete(ctx context.Context, key interface{}) error {
args := c.Called(ctx, key)
return args.Error(0)
}

func (f *MockHandlerCache) Unlock(ctx context.Context, key interface{}) error {
args := f.Called(ctx, key)
func (c *MockHandlerCache) Unlock(ctx context.Context, key interface{}) error {
args := c.Called(ctx, key)
return args.Error(0)
}

func (f *MockHandlerCache) IsLocked(ctx context.Context, key interface{}) (bool, error) {
args := f.Called(ctx, key)
func (c *MockHandlerCache) IsLocked(ctx context.Context, key interface{}) (bool, error) {
args := c.Called(ctx, key)
return args.Bool(0), args.Error(1)
}

func (f *MockHandlerCache) ForceUnlock(ctx context.Context, key interface{}) error {
args := f.Called(ctx, key)
func (c *MockHandlerCache) ForceUnlock(ctx context.Context, key interface{}) error {
args := c.Called(ctx, key)
return args.Error(0)
}

func (f *MockHandlerCache) ContainsKey(ctx context.Context, key interface{}) (bool, error) {
args := f.Called(ctx, key)
func (c *MockHandlerCache) ContainsKey(ctx context.Context, key interface{}) (bool, error) {
args := c.Called(ctx, key)
return args.Bool(0), args.Error(1)
}

func (f *MockHandlerCache) Clear(ctx context.Context) error {
args := f.Called(ctx)
func (c *MockHandlerCache) Clear(ctx context.Context) error {
args := c.Called(ctx)
return args.Error(0)
}

func (f *MockHandlerCache) Lock(ctx context.Context, key interface{}) error {
args := f.Called(ctx, key)
func (c *MockHandlerCache) Lock(ctx context.Context, key interface{}) error {
args := c.Called(ctx, key)
return args.Error(0)
}
2 changes: 2 additions & 0 deletions internal/test/health_check_mock.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
//
// SPDX-License-Identifier: Apache-2.0

//go:build testing

package test

import (
Expand Down
2 changes: 2 additions & 0 deletions internal/test/kafkahandler_mock.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
//
// SPDX-License-Identifier: Apache-2.0

//go:build testing

package test

import (
Expand Down
2 changes: 2 additions & 0 deletions internal/test/mongohandler_mock.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
//
// SPDX-License-Identifier: Apache-2.0

//go:build testing

package test

import (
Expand Down
2 changes: 2 additions & 0 deletions internal/test/republishing_mock.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
//
// SPDX-License-Identifier: Apache-2.0

//go:build testing

package test

import (
Expand Down
2 changes: 2 additions & 0 deletions internal/test/waitinghandler_mock.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
//
// SPDX-License-Identifier: Apache-2.0

//go:build testing

package test

import "github.com/stretchr/testify/mock"
Expand Down

0 comments on commit ecff49f

Please sign in to comment.