Skip to content

Commit

Permalink
fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
totegamma committed Feb 25, 2024
1 parent 0793f71 commit c608e56
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 8 deletions.
2 changes: 1 addition & 1 deletion cmd/api/wire_gen.go

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

2 changes: 1 addition & 1 deletion cmd/gateway/wire_gen.go

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

5 changes: 4 additions & 1 deletion x/key/repository_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ func TestRepository(t *testing.T) {
db, cleanup_db := testutil.CreateDB()
defer cleanup_db()

repo := NewRepository(db)
mc, cleanup_mc := testutil.CreateMC()
defer cleanup_mc()

repo := NewRepository(db, mc)

newkey := core.Key{
ID: "CKb72AAc9dcF088F7088b6718BE5a494fBB3861439",
Expand Down
6 changes: 6 additions & 0 deletions x/key/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,7 @@ func (s *service) GetKeyResolution(ctx context.Context, keyID string) ([]core.Ke
defer span.End()

var keys []core.Key
var currentDepth = 0
for {
if IsCCID(keyID) {
return keys, nil
Expand All @@ -335,6 +336,11 @@ func (s *service) GetKeyResolution(ctx context.Context, keyID string) ([]core.Ke

keys = append(keys, key)
keyID = key.Parent

currentDepth++
if currentDepth >= 8 {
return nil, fmt.Errorf("KeyDepth is too deep")
}
}
}

Expand Down
5 changes: 4 additions & 1 deletion x/key/service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,16 @@ func TestService(t *testing.T) {
db, cleanup_db := testutil.CreateDB()
defer cleanup_db()

mc, cleanup_mc := testutil.CreateMC()
defer cleanup_mc()

ctrl := gomock.NewController(t)
defer ctrl.Finish()

mockEntity := mock_entity.NewMockService(ctrl)
mockEntity.EXPECT().ResolveHost(gomock.Any(), gomock.Any(), gomock.Any()).Return("", nil).AnyTimes()

test_repo := NewRepository(db)
test_repo := NewRepository(db, mc)
test_service := NewService(test_repo, mockEntity, util.Config{})

// Test1. 登録してないサブキーで署名されたオブジェクトを検証する
Expand Down
8 changes: 4 additions & 4 deletions x/stream/mock/service.go

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

0 comments on commit c608e56

Please sign in to comment.