Skip to content

Commit

Permalink
Update go fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
adlio committed Apr 8, 2023
1 parent 83feb40 commit e6f2f7a
Show file tree
Hide file tree
Showing 12 changed files with 1 addition and 25 deletions.
1 change: 0 additions & 1 deletion applied-migration.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ type AppliedMigration struct {

// GetAppliedMigrations retrieves all already-applied migrations in a map keyed
// by the migration IDs
//
func (m Migrator) GetAppliedMigrations(db Queryer) (applied map[string]*AppliedMigration, err error) {
applied = make(map[string]*AppliedMigration)

Expand Down
1 change: 0 additions & 1 deletion doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,4 @@
// to its .Apply() method.
//
// See the package's README.md file for more usage instructions.
//
package schema
3 changes: 1 addition & 2 deletions embed_go116.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ import (
//
// Example usage:
//
// FSMigrations(embeddedFS, "my-migrations/*.sql")
//
// FSMigrations(embeddedFS, "my-migrations/*.sql")
func FSMigrations(filesystem fs.FS, glob string) (migrations []*Migration, err error) {
migrations = make([]*Migration, 0)

Expand Down
1 change: 0 additions & 1 deletion file.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import (

// MigrationIDFromFilename removes directory paths and extensions
// from the filename to make a friendlier Migration ID
//
func MigrationIDFromFilename(filename string) string {
return strings.TrimSuffix(filepath.Base(filename), filepath.Ext(filename))
}
Expand Down
1 change: 0 additions & 1 deletion main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import (
// Docker running on the local machine and launches testing database
// containers to which we then connect and store the connection in a package
// global variable
//
func TestMain(m *testing.M) {
pool, err := dockertest.NewPool("")
if err != nil {
Expand Down
4 changes: 0 additions & 4 deletions migrator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ func TestLockAndUnlock(t *testing.T) {
// lexical order rather than the order they were provided in the slice. This is
// also the primary test to assert that the data in the tracking table is
// all correct.
//
func TestApplyInLexicalOrder(t *testing.T) {
withEachTestDB(t, func(t *testing.T, tdb *TestDB) {

Expand Down Expand Up @@ -117,7 +116,6 @@ func TestApplyInLexicalOrder(t *testing.T) {
// TestFailedMigration ensures that a migration with a syntax error triggers
// an expected error when Apply() is run. This test is run on every dialect
// and every test database instance
//
func TestFailedMigration(t *testing.T) {
withEachTestDB(t, func(t *testing.T, tdb *TestDB) {

Expand Down Expand Up @@ -154,7 +152,6 @@ func TestFailedMigration(t *testing.T) {
// connections to each test database and attempts to call .Apply() on them all
// concurrently. The migrations include an INSERT statement, which allows us
// to count to ensure that each unique migration was only run once.
//
func TestSimultaneousApply(t *testing.T) {
concurrency := 4
dataTable := fmt.Sprintf("data%d", rand.Int()) // #nosec we don't need cryptographic security here
Expand Down Expand Up @@ -278,7 +275,6 @@ func TestMultiSchemaSupport(t *testing.T) {

// TestRunFailure ensures that a low-level connection or query-related failure
// triggers an expected error.
//
func TestRunFailure(t *testing.T) {
bq := BadQueryer{}
m := makeTestMigrator()
Expand Down
2 changes: 0 additions & 2 deletions mysql.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ func (m mysqlDialect) InsertAppliedMigration(ctx context.Context, tx Queryer, ta
}

// GetAppliedMigrations retrieves all data from the migrations tracking table
//
func (m mysqlDialect) GetAppliedMigrations(ctx context.Context, tx Queryer, tableName string) (migrations []*AppliedMigration, err error) {
migrations = make([]*AppliedMigration, 0)

Expand Down Expand Up @@ -96,7 +95,6 @@ func (m mysqlDialect) GetAppliedMigrations(ctx context.Context, tx Queryer, tabl

// QuotedTableName returns the string value of the name of the migration
// tracking table after it has been quoted for MySQL
//
func (m mysqlDialect) QuotedTableName(schemaName, tableName string) string {
if schemaName == "" {
return m.quotedIdent(tableName)
Expand Down
3 changes: 0 additions & 3 deletions options.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ type Option func(m Migrator) Migrator

// WithDialect builds an Option which will set the supplied
// dialect on a Migrator. Usage: NewMigrator(WithDialect(MySQL))
//
func WithDialect(dialect Dialect) Option {
return func(m Migrator) Migrator {
m.Dialect = dialect
Expand All @@ -23,7 +22,6 @@ func WithDialect(dialect Dialect) Option {
// qualifier (for example, WithTableName("public", "schema_migrations") would
// assign the table named "schema_migrations" in the the default "public"
// schema for Postgres)
//
func WithTableName(names ...string) Option {
return func(m Migrator) Migrator {
switch len(names) {
Expand Down Expand Up @@ -57,7 +55,6 @@ type Logger interface {

// WithLogger builds an Option which will set the supplied Logger
// on a Migrator. Usage: NewMigrator(WithLogger(logrus.New()))
//
func WithLogger(logger Logger) Option {
return func(m Migrator) Migrator {
m.Logger = logger
Expand Down
2 changes: 0 additions & 2 deletions postgres.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ func (p postgresDialect) InsertAppliedMigration(ctx context.Context, tx Queryer,
}

// GetAppliedMigrations retrieves all data from the migrations tracking table
//
func (p postgresDialect) GetAppliedMigrations(ctx context.Context, tx Queryer, tableName string) (migrations []*AppliedMigration, err error) {
migrations = make([]*AppliedMigration, 0)

Expand Down Expand Up @@ -97,7 +96,6 @@ func (p postgresDialect) GetAppliedMigrations(ctx context.Context, tx Queryer, t

// QuotedTableName returns the string value of the name of the migration
// tracking table after it has been quoted for Postgres
//
func (p postgresDialect) QuotedTableName(schemaName, tableName string) string {
if schemaName == "" {
return p.QuotedIdent(tableName)
Expand Down
1 change: 0 additions & 1 deletion schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ type Queryer interface {
}

// Transactor defines the interface for the Begin method from the *sql.DB
//
type Transactor interface {
BeginTx(ctx context.Context, opts *sql.TxOptions) (*sql.Tx, error)
}
1 change: 0 additions & 1 deletion sqlite.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ func (s *sqliteDialect) InsertAppliedMigration(ctx context.Context, tx Queryer,
}

// GetAppliedMigrations retrieves all data from the migrations tracking table
//
func (s sqliteDialect) GetAppliedMigrations(ctx context.Context, tx Queryer, tableName string) (migrations []*AppliedMigration, err error) {
migrations = make([]*AppliedMigration, 0)

Expand Down
6 changes: 0 additions & 6 deletions testdb_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import (

// TestDB represents a specific database instance against which we would like
// to run database migration tests.
//
type TestDB struct {
Dialect Dialect
Driver string
Expand Down Expand Up @@ -55,7 +54,6 @@ func (c *TestDB) DatabaseName() string {

// Port asks Docker for the host-side port we can use to connect to the
// relevant container's database port.
//
func (c *TestDB) Port() string {
switch c.Driver {
case MySQLDriverName:
Expand All @@ -78,7 +76,6 @@ func (c *TestDB) IsSQLite() bool {

// DockerEnvars computes the environment variables that are needed for a
// docker instance.
//
func (c *TestDB) DockerEnvars() []string {
switch c.Driver {
case PostgresDriverName:
Expand Down Expand Up @@ -156,7 +153,6 @@ func (c *TestDB) DSN() string {
// instances, this function triggers the `docker run` call. For SQLite-based
// test instances, this creates the data file. In all cases, we verify that
// the database is connectable via a test connection.
//
func (c *TestDB) Init(pool *dockertest.Pool) {
var err error

Expand Down Expand Up @@ -208,7 +204,6 @@ func (c *TestDB) Init(pool *dockertest.Pool) {

// Connect creates an additional *database/sql.DB connection for a particular
// test database.
//
func (c *TestDB) Connect(t *testing.T) *sql.DB {
db, err := sql.Open(c.Driver, c.DSN())
if err != nil {
Expand All @@ -220,7 +215,6 @@ func (c *TestDB) Connect(t *testing.T) *sql.DB {
// Cleanup should be called after all tests with a database instance are
// complete. For dockertest-based tests, it deletes the docker containers.
// For SQLite tests, it deletes the database file from the temp directory.
//
func (c *TestDB) Cleanup(pool *dockertest.Pool) {
var err error

Expand Down

0 comments on commit e6f2f7a

Please sign in to comment.