Skip to content

Commit

Permalink
test: add unit test for /arana/pkg/sequence/... package
Browse files Browse the repository at this point in the history
  • Loading branch information
Mulavar committed Sep 18, 2023
1 parent e90d5b8 commit d1c7dfd
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 7 deletions.
1 change: 1 addition & 0 deletions .licenserc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ header: # `header` section is configurations for source codes license header.
- 'pkg/resolver/mysql/encoding.go'
- 'pkg/resolver/mysql/sql_error.go'
- 'pkg/resolver/mysql/type.go'
- 'pkg/runtime/mock_runtime.go'
- 'VERSION'
- ".errcheck-exclude"
- ".golangci.yml"
Expand Down
7 changes: 3 additions & 4 deletions testdata/mock_rt_runtime.go → pkg/runtime/mock_runtime.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pkg/runtime/runtime.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* limitations under the License.
*/

//go:generate mockgen -destination=../../testdata/mock_rt_runtime.go -package=testdata . Runtime
//go:generate mockgen -destination=./mock_runtime.go -package=runtime . Runtime
package runtime

import (
Expand Down
2 changes: 1 addition & 1 deletion pkg/sequence/group/group_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ func Test_groupSequence_Acquire(t *testing.T) {
mockTx.EXPECT().Rollback(gomock.Any()).Return(mockRes, uint16(0), nil).AnyTimes()

// build mock runtime
mockRt := testdata.NewMockRuntime(ctrl)
mockRt := runtime.NewMockRuntime(ctrl)
mockRt.EXPECT().Begin(gomock.Any()).Return(mockTx, nil).AnyTimes()

runtime.Register(tenant, schema, mockRt)
Expand Down
3 changes: 2 additions & 1 deletion pkg/sequence/snowflake/snowflake_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import (

import (
"github.com/arana-db/arana/pkg/proto"
"github.com/arana-db/arana/pkg/runtime"
"github.com/arana-db/arana/testdata"
)

Expand Down Expand Up @@ -68,7 +69,7 @@ func Test_snowflakeSequence_Acquire(t *testing.T) {
mockTx.EXPECT().Rollback(gomock.Any()).Return(mockRes, uint16(0), nil).AnyTimes()

// build mock runtime
mockRt := testdata.NewMockRuntime(ctrl)
mockRt := runtime.NewMockRuntime(ctrl)
mockRt.EXPECT().Begin(gomock.Any()).Return(mockTx, nil).AnyTimes()

ctx := context.WithValue(context.Background(), proto.RuntimeCtxKey{}, mockRt)
Expand Down

0 comments on commit d1c7dfd

Please sign in to comment.