Skip to content

Commit

Permalink
update tree structure for grafeas-rds to match other storage solutions
Browse files Browse the repository at this point in the history
  • Loading branch information
hkadakia committed Nov 19, 2021
1 parent 1d10634 commit 2534e39
Show file tree
Hide file tree
Showing 26 changed files with 51 additions and 49 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Copyright Yahoo 2021
# Licensed under the terms of the Apache License 2.0.
# See LICENSE file in project root for terms.
rds/bin/mockgen
go/v1beta1/storage/bin/mockgen
.idea/
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ If the underlying database were PostgreSQL, the code would look like this:
import (
"log"

"github.com/theparanoids/grafeas-rds/rds"
"github.com/theparanoids/grafeas-rds/go/v1beta1/storage"
"github.com/grafeas/grafeas/go/v1beta1/storage"
"github.com/lib/pq"
)
Expand Down Expand Up @@ -70,10 +70,10 @@ func main() {

## Configuration

A valid configuration file can be found [here](rds/config/testdata/valid.yaml);
A valid configuration file can be found [here](go/config/testdata/valid.yaml);
it can be directly plugged into a configuration file for Grafeas server.

Some default values are also provided in [`config.go`](rds/config/config.go).
Some default values are also provided in [`config.go`](go/config/config.go).

## Contribute

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

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

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

4 changes: 2 additions & 2 deletions rds/driver_mock_test.go → go/v1beta1/mocks/driver_mock.go

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

6 changes: 3 additions & 3 deletions rds/storage_mock_test.go → go/v1beta1/mocks/storage_mock.go

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

4 changes: 2 additions & 2 deletions rds/connector.go → go/v1beta1/storage/connector.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright Yahoo 2021
// Licensed under the terms of the Apache License 2.0.
// See LICENSE file in project root for terms.
package rds
package storage

import (
"database/sql/driver"
Expand All @@ -14,7 +14,7 @@ import (
"github.com/aws/aws-sdk-go/service/rds/rdsutils"
"golang.org/x/net/context"

"github.com/theparanoids/grafeas-rds/rds/config"
"github.com/theparanoids/grafeas-rds/go/config"
)

const (
Expand Down
16 changes: 8 additions & 8 deletions rds/connector_test.go → go/v1beta1/storage/connector_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright Yahoo 2021
// Licensed under the terms of the Apache License 2.0.
// See LICENSE file in project root for terms.
package rds
package storage

import (
"bytes"
Expand All @@ -14,8 +14,8 @@ import (

"github.com/aws/aws-sdk-go/aws/credentials"
"github.com/golang/mock/gomock"

"github.com/theparanoids/grafeas-rds/rds/config"
"github.com/theparanoids/grafeas-rds/go/config"
"github.com/theparanoids/grafeas-rds/go/v1beta1/mocks"
)

func TestNewConnector(t *testing.T) {
Expand Down Expand Up @@ -44,8 +44,8 @@ func TestNewConnector(t *testing.T) {
}

mockCtrl := gomock.NewController(t)
mockDriver := NewMockDriver(mockCtrl)
mockCredentialsCreator := NewMockCredentialsCreator(mockCtrl)
mockDriver := mocks.NewMockDriver(mockCtrl)
mockCredentialsCreator := mocks.NewMockCredentialsCreator(mockCtrl)
for _, tt := range tests {
tt := tt
t.Run(tt.name, func(t *testing.T) {
Expand Down Expand Up @@ -91,7 +91,7 @@ func TestConnectorConnect(t *testing.T) {
t.Parallel()

mockCtrl := gomock.NewController(t)
mockDriver := NewMockDriver(mockCtrl)
mockDriver := mocks.NewMockDriver(mockCtrl)
c := &connector{
dsn: "some dsn",
driver: mockDriver,
Expand All @@ -107,7 +107,7 @@ func TestConnectorDriver(t *testing.T) {
t.Parallel()

mockCtrl := gomock.NewController(t)
want := NewMockDriver(mockCtrl)
want := mocks.NewMockDriver(mockCtrl)
c := &connector{driver: want}
got := c.Driver()
if got != want {
Expand Down Expand Up @@ -139,7 +139,7 @@ func TestSetupIAMAuth(t *testing.T) {
}

mockCtrl := gomock.NewController(t)
mockCredentialsCreator := NewMockCredentialsCreator(mockCtrl)
mockCredentialsCreator := mocks.NewMockCredentialsCreator(mockCtrl)
for _, tt := range tests {
tt := tt
t.Run(tt.name, func(t *testing.T) {
Expand Down
12 changes: 6 additions & 6 deletions rds/gen.sh → go/v1beta1/storage/gen.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ main() {
export GOBIN
go install github.com/golang/mock/mockgen

# Make sure that we are using the mockgen which is just built to generate mock code.
# Make sure that we are using the mockgen which is just built to generate mocks code.
export PATH=$GOBIN:$PATH
mockgen -package rds -destination driver_mock_test.go database/sql/driver Driver
mockgen -package rds -destination conn_pool_mgr_mock_test.go . ConnPoolMgr
mockgen -package rds -destination storage_mock_test.go . Storage
mockgen -package rds -destination credentials_creator_mock_test.go . CredentialsCreator
mockgen -package rds -destination storage_creator_mock_test.go . StorageCreator
mockgen -package mocks -destination ../mocks/driver_mock.go database/sql/driver Driver
mockgen -package mocks -destination ../mocks/conn_pool_mgr_mock.go . ConnPoolMgr
mockgen -package mocks -destination ../mocks/storage_mock.go . Storage
mockgen -package mocks -destination ../mocks/credentials_creator_mock.go . CredentialsCreator
mockgen -package storage -destination storage_creator_mock_test.go . StorageCreator
}

main
2 changes: 1 addition & 1 deletion rds/generate.go → go/v1beta1/storage/generate.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Copyright Yahoo 2021
// Licensed under the terms of the Apache License 2.0.
// See LICENSE file in project root for terms.
package rds
package storage

//go:generate ./gen.sh
4 changes: 2 additions & 2 deletions rds/storage.go → go/v1beta1/storage/storage.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright Yahoo 2021
// Licensed under the terms of the Apache License 2.0.
// See LICENSE file in project root for terms.
package rds
package storage

import (
"context"
Expand All @@ -13,7 +13,7 @@ import (
"github.com/aws/aws-sdk-go/aws/credentials"
"github.com/grafeas/grafeas/go/config"
"github.com/grafeas/grafeas/go/v1beta1/storage"
rdsconfig "github.com/theparanoids/grafeas-rds/rds/config"
rdsconfig "github.com/theparanoids/grafeas-rds/go/config"
)

const (
Expand Down

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

21 changes: 11 additions & 10 deletions rds/storage_test.go → go/v1beta1/storage/storage_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright Yahoo 2021
// Licensed under the terms of the Apache License 2.0.
// See LICENSE file in project root for terms.
package rds
package storage

import (
"errors"
Expand All @@ -10,10 +10,11 @@ import (
"time"

"github.com/aws/aws-sdk-go/aws/credentials"
gomock "github.com/golang/mock/gomock"
"github.com/golang/mock/gomock"
"github.com/grafeas/grafeas/go/config"

rdsconfig "github.com/theparanoids/grafeas-rds/rds/config"
rdsconfig "github.com/theparanoids/grafeas-rds/go/config"
"github.com/theparanoids/grafeas-rds/go/v1beta1/mocks"
)

func TestStorageProviderProvide(t *testing.T) {
Expand All @@ -38,9 +39,9 @@ func TestStorageProviderProvide(t *testing.T) {
name string
expect func(*testCase)
conf config.StorageConfiguration
store *MockStorage
store *mocks.MockStorage
storeCreator *MockStorageCreator
credsCreator *MockCredentialsCreator
credsCreator *mocks.MockCredentialsCreator
wantErrMsg string
}
tests := []testCase{
Expand All @@ -57,9 +58,9 @@ func TestStorageProviderProvide(t *testing.T) {
tt.store.EXPECT().SetConnMaxIdleTime(time.Duration(conf.ConnMaxIdleTimeInSeconds) * time.Second).Times(1)
},
conf: validConf,
store: NewMockStorage(mockCtrl),
store: mocks.NewMockStorage(mockCtrl),
storeCreator: NewMockStorageCreator(mockCtrl),
credsCreator: NewMockCredentialsCreator(mockCtrl),
credsCreator: mocks.NewMockCredentialsCreator(mockCtrl),
},
{
name: "invalid config",
Expand All @@ -73,7 +74,7 @@ func TestStorageProviderProvide(t *testing.T) {
tt.credsCreator.EXPECT().Create(gomock.Any()).Times(1).Return(credentials.AnonymousCredentials, nil)
},
conf: validConf,
credsCreator: NewMockCredentialsCreator(mockCtrl),
credsCreator: mocks.NewMockCredentialsCreator(mockCtrl),
wantErrMsg: errMsgInitConnector,
},
{
Expand All @@ -84,7 +85,7 @@ func TestStorageProviderProvide(t *testing.T) {
},
conf: validConf,
storeCreator: NewMockStorageCreator(mockCtrl),
credsCreator: NewMockCredentialsCreator(mockCtrl),
credsCreator: mocks.NewMockCredentialsCreator(mockCtrl),
wantErrMsg: errMsgInitStorage,
},
}
Expand All @@ -96,7 +97,7 @@ func TestStorageProviderProvide(t *testing.T) {
if tt.expect != nil {
tt.expect(&tt)
}
storageProvider := NewGrafeasStorageProvider(NewMockDriver(mockCtrl), tt.credsCreator, tt.storeCreator)
storageProvider := NewGrafeasStorageProvider(mocks.NewMockDriver(mockCtrl), tt.credsCreator, tt.storeCreator)
storage, err := storageProvider.Provide("", &tt.conf)
if (err != nil) != (tt.wantErrMsg != "") {
if err != nil {
Expand Down
3 changes: 2 additions & 1 deletion rds/tools.go → go/v1beta1/storage/tools.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@
// Licensed under the terms of the Apache License 2.0.
// See LICENSE file in project root for terms.
//
//go:build tools
// +build tools

package rds
package storage

// Although gomock is already in go.mod because
// it is also used as a library by the testing code,
Expand Down

0 comments on commit 2534e39

Please sign in to comment.