Skip to content
This repository has been archived by the owner on Mar 11, 2021. It is now read-only.

Commit

Permalink
Replace buit-in dbcleaner with fabric8-common's one (#789)
Browse files Browse the repository at this point in the history
replace built-in db_cleaner with common's one
also:
- remove logrus and gorm as they already come with
`fabric8-common`
- remove unused ("stanza") dependencies in Gopkg.toml

fixes #788

Signed-off-by: Xavier Coulon <[email protected]>
  • Loading branch information
xcoulon authored Feb 21, 2019
1 parent 90bcc79 commit e8328fe
Show file tree
Hide file tree
Showing 7 changed files with 58 additions and 162 deletions.
30 changes: 21 additions & 9 deletions Gopkg.lock

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

22 changes: 1 addition & 21 deletions Gopkg.toml
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,6 @@ required = [
"github.com/gojuno/minimock/cmd/minimock"
]

[[constraint]]
name = "github.com/ajg/form"
version = "1.5.0"

[[constraint]]
name = "github.com/dgrijalva/jwt-go"
version = "3.0.0"
Expand All @@ -61,10 +57,6 @@ required = [
name = "github.com/goadesign/goa"
version = "1.3.0"

[[constraint]]
name = "github.com/jinzhu/gorm"
version = "1.9.1"

[[constraint]]
name = "github.com/lib/pq"
version = "1.0.0"
Expand All @@ -77,10 +69,6 @@ required = [
name = "github.com/satori/go.uuid"
version = "1.2.0"

[[constraint]]
name = "github.com/sirupsen/logrus"
version = "0.11.2"

[[constraint]]
name = "github.com/stretchr/testify"
version = "1.2.1"
Expand Down Expand Up @@ -111,7 +99,7 @@ required = [

[[constraint]]
name = "github.com/fabric8-services/fabric8-common"
revision = "a85e65e22cfc18d7c2004317d340ad328ca8dcd1"
revision = "988ec38ba27dc10cc955f19cce227e7cd8d58528"

[[constraint]]
name = "github.com/jstemmer/go-junit-report"
Expand All @@ -125,10 +113,6 @@ required = [
name = "github.com/getsentry/raven-go"
revision = "563b81fc02b75d664e54da31f787c2cc2186780b"

[[constraint]]
name = "github.com/dnaeon/go-vcr"
revision= "9d71b8a6df86e00127f96bc8dabc09856ab8afdb"

[[constraint]]
name = "github.com/gojuno/minimock"
revision = "a5502dd2746ee6fc3fd58ad83d701d25e14d68d1"
Expand All @@ -137,10 +121,6 @@ revision= "9d71b8a6df86e00127f96bc8dabc09856ab8afdb"
go-tests = true
unused-packages = true

[[constraint]]
name = "github.com/fsnotify/fsnotify"
version = "1.4.7"

[[constraint]]
name = "gopkg.in/h2non/gock.v1"
version = "1.0.12"
6 changes: 3 additions & 3 deletions application/application_db_calls_bench_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ import (
"golang.org/x/net/context"

"github.com/fabric8-services/fabric8-auth/gormsupport"
"github.com/fabric8-services/fabric8-auth/gormsupport/cleaner"
gormbench "github.com/fabric8-services/fabric8-auth/gormtestsupport/benchmark"
"github.com/fabric8-services/fabric8-auth/migration"
testsupport "github.com/fabric8-services/fabric8-auth/test"
"github.com/fabric8-services/fabric8-common/test/suite"

account "github.com/fabric8-services/fabric8-auth/authentication/account/repository"
"github.com/jinzhu/gorm"
Expand All @@ -27,7 +27,7 @@ type Identity struct {

type BenchDbOperations struct {
gormbench.DBBenchSuite
clean func()
clean func() error
repo account.IdentityRepository
ctx context.Context
dbPq *sql.DB
Expand Down Expand Up @@ -55,7 +55,7 @@ func (s *BenchDbOperations) SetupSuite() {
}

func (s *BenchDbOperations) SetupBenchmark() {
s.clean = cleaner.DeleteCreatedEntities(s.DB)
s.clean = suite.DeleteCreatedEntities(s.DB, s.Configuration)
s.repo = account.NewIdentityRepository(s.DB)

s.identity = &account.Identity{
Expand Down
2 changes: 1 addition & 1 deletion application/transaction/transaction_bench_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ import (
"github.com/fabric8-services/fabric8-auth/application/transaction"
account "github.com/fabric8-services/fabric8-auth/authentication/account/repository"
"github.com/fabric8-services/fabric8-auth/gormapplication"
"github.com/fabric8-services/fabric8-auth/gormsupport/cleaner"
gormbench "github.com/fabric8-services/fabric8-auth/gormtestsupport/benchmark"
"github.com/fabric8-services/fabric8-auth/migration"
testsupport "github.com/fabric8-services/fabric8-auth/test"
testsuite "github.com/fabric8-services/fabric8-common/test/suite"
)

type BenchTransactional struct {
Expand Down
42 changes: 25 additions & 17 deletions configuration/configuration.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
"github.com/pkg/errors"
log "github.com/sirupsen/logrus"
"github.com/spf13/viper"
"gopkg.in/yaml.v2"
yaml "gopkg.in/yaml.v2"
)

// String returns the current configuration as a string
Expand All @@ -40,22 +40,23 @@ const (
//
//------------------------------------------------------------------------------------------------------------------

varHTTPAddress = "http.address"
varMetricsHTTPAddress = "metrics.http.address"
varDeveloperModeEnabled = "developer.mode.enabled"
varCleanTestDataEnabled = "clean.test.data"
varDBLogsEnabled = "enable.db.logs"
varNotApprovedRedirect = "notapproved.redirect"
varHeaderMaxLength = "header.maxlength"
varUsersListLimit = "users.listlimit"
defaultConfigFile = "config.yaml"
varValidRedirectURLs = "redirect.valid"
varLogLevel = "log.level"
varLogJSON = "log.json"
varEmailVerifiedRedirectURL = "email.verify.url"
varInvitationAcceptedRedirectURL = "invitation.accepted.url"
varInternalUsersEmailAddressSuffix = "internal.users.email.address.domain"
varIgnoreEmailInProd = "ignore.email.prod"
varHTTPAddress = "http.address"
varMetricsHTTPAddress = "metrics.http.address"
varDeveloperModeEnabled = "developer.mode.enabled"
varCleanTestDataEnabled = "clean.test.data"
varCleanTestDataErrorReportingRequired = "error.reporting.required"
varDBLogsEnabled = "enable.db.logs"
varNotApprovedRedirect = "notapproved.redirect"
varHeaderMaxLength = "header.maxlength"
varUsersListLimit = "users.listlimit"
defaultConfigFile = "config.yaml"
varValidRedirectURLs = "redirect.valid"
varLogLevel = "log.level"
varLogJSON = "log.json"
varEmailVerifiedRedirectURL = "email.verify.url"
varInvitationAcceptedRedirectURL = "invitation.accepted.url"
varInternalUsersEmailAddressSuffix = "internal.users.email.address.domain"
varIgnoreEmailInProd = "ignore.email.prod"

//------------------------------------------------------------------------------------------------------------------
//
Expand Down Expand Up @@ -570,6 +571,8 @@ func (c *ConfigurationData) setConfigDefaults() {

// By default, test data should be cleaned from DB, unless explicitely said otherwise.
c.v.SetDefault(varCleanTestDataEnabled, true)
// By default, error should be reported while cleaning test data from DB.
c.v.SetDefault(varCleanTestDataErrorReportingRequired, true)
// By default, DB logs are not output in the console
c.v.SetDefault(varDBLogsEnabled, false)

Expand Down Expand Up @@ -744,6 +747,11 @@ func (c *ConfigurationData) IsCleanTestDataEnabled() bool {
return c.v.GetBool(varCleanTestDataEnabled)
}

// IsCleanTestDataErrorReportingRequired returns `true` if there is any error while cleaning test data after each test. (default: true)
func (c *ConfigurationData) IsCleanTestDataErrorReportingRequired() bool {
return c.v.GetBool(varCleanTestDataErrorReportingRequired)
}

// IsDBLogsEnabled returns `true` if the DB logs (ie, SQL queries) should be output in the console. (default: false)
func (c *ConfigurationData) IsDBLogsEnabled() bool {
return c.v.GetBool(varDBLogsEnabled)
Expand Down
105 changes: 0 additions & 105 deletions gormsupport/cleaner/db_clean.go

This file was deleted.

Loading

0 comments on commit e8328fe

Please sign in to comment.