Skip to content

Commit

Permalink
Merge branch 'master' into fix-embedded-primary-field
Browse files Browse the repository at this point in the history
  • Loading branch information
Fs02 authored Oct 21, 2023
2 parents 9c3068f + 2e07fc1 commit 2f08dfd
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
1 change: 1 addition & 0 deletions adapter.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (

// Adapter interface
type Adapter interface {
Name() string
Close() error

Instrumentation(instrumenter Instrumenter)
Expand Down
5 changes: 5 additions & 0 deletions adapter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,3 +90,8 @@ func (ta *testAdapter) Exec(ctx context.Context, stmt string, args []any) (int64
mockArgs := ta.Called(ctx, stmt, args)
return int64(mockArgs.Int(0)), int64(mockArgs.Int(1)), mockArgs.Error(2)
}

func (ta *testAdapter) Name() string {
args := ta.Called()
return args.String(0)
}
16 changes: 13 additions & 3 deletions repository_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,7 @@ func TestNew(t *testing.T) {
}

func TestRepository_Instrumentation(t *testing.T) {
var (
repo = repository{rootAdapter: &testAdapter{}}
)
repo := repository{rootAdapter: &testAdapter{}}

assert.Nil(t, repo.instrumenter)
assert.NotPanics(t, func() {
Expand All @@ -75,6 +73,18 @@ func TestRepository_Ping(t *testing.T) {
adapter.AssertExpectations(t)
}

func TestRepository_AdapterName(t *testing.T) {
var (
adapter = &testAdapter{}
repo = New(adapter)
)

adapter.On("Name").Return("test").Once()

assert.Equal(t, "test", repo.Adapter(context.TODO()).Name())
adapter.AssertExpectations(t)
}

func TestRepository_Iterate(t *testing.T) {
var (
user User
Expand Down

0 comments on commit 2f08dfd

Please sign in to comment.