Skip to content

Commit

Permalink
don't use got.New
Browse files Browse the repository at this point in the history
  • Loading branch information
serprex committed Dec 22, 2023
1 parent de34287 commit 9212271
Show file tree
Hide file tree
Showing 9 changed files with 66 additions and 98 deletions.
8 changes: 3 additions & 5 deletions flow/connectors/postgres/postgres_repl_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,13 @@ import (
)

type PostgresReplicationSnapshotTestSuite struct {
got.G
t *testing.T

connector *PostgresConnector
schema string
}

func setupSuite(t *testing.T, g got.G) PostgresReplicationSnapshotTestSuite {
func setupSuite(t *testing.T) PostgresReplicationSnapshotTestSuite {
connector, err := NewPostgresConnector(context.Background(), &protos.PostgresConfig{
Host: "localhost",
Port: 7132,
Expand Down Expand Up @@ -66,7 +65,6 @@ func setupSuite(t *testing.T, g got.G) PostgresReplicationSnapshotTestSuite {
require.NoError(t, err)

return PostgresReplicationSnapshotTestSuite{
G: g,
t: t,
connector: connector,
schema: schema,
Expand Down Expand Up @@ -111,12 +109,12 @@ func (suite PostgresReplicationSnapshotTestSuite) TearDownSuite() {
err = teardownTx.Commit(context.Background())
require.NoError(suite.t, err)

suite.True(suite.connector.ConnectionActive() == nil)
require.True(suite.t, suite.connector.ConnectionActive() == nil)

err = suite.connector.Close()
require.NoError(suite.t, err)

suite.False(suite.connector.ConnectionActive() == nil)
require.False(suite.t, suite.connector.ConnectionActive() == nil)
}

func (suite PostgresReplicationSnapshotTestSuite) TestSimpleSlotCreation() {
Expand Down
17 changes: 7 additions & 10 deletions flow/connectors/postgres/postgres_schema_delta_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,20 @@ import (
)

type PostgresSchemaDeltaTestSuite struct {
got.G
t *testing.T

connector *PostgresConnector
}

const schemaDeltaTestSchemaName = "pgschema_delta_test"

func setupSchemaDeltaSuite(t *testing.T, g got.G) PostgresSchemaDeltaTestSuite {
func setupSchemaDeltaSuite(t *testing.T) PostgresSchemaDeltaTestSuite {
connector, err := NewPostgresConnector(context.Background(), &protos.PostgresConfig{
Host: "localhost",
Port: 7132,
User: "postgres",
Password: "postgres",
Database: "postgres",
})
}, false)
require.NoError(t, err)

Expand All @@ -49,7 +47,6 @@ func setupSchemaDeltaSuite(t *testing.T, g got.G) PostgresSchemaDeltaTestSuite {
err = setupTx.Commit(context.Background())
require.NoError(t, err)
return PostgresSchemaDeltaTestSuite{
G: g,
t: t,
connector: connector,
}
Expand All @@ -70,10 +67,10 @@ func (suite PostgresSchemaDeltaTestSuite) TearDownSuite() {
err = teardownTx.Commit(context.Background())
require.NoError(suite.t, err)

suite.True(suite.connector.ConnectionActive() == nil)
require.True(suite.t, suite.connector.ConnectionActive() == nil)
err = suite.connector.Close()
require.NoError(suite.t, err)
suite.False(suite.connector.ConnectionActive() == nil)
require.False(suite.t, suite.connector.ConnectionActive() == nil)
}

func (suite PostgresSchemaDeltaTestSuite) TestSimpleAddColumn() {
Expand All @@ -96,7 +93,7 @@ func (suite PostgresSchemaDeltaTestSuite) TestSimpleAddColumn() {
TableIdentifiers: []string{tableName},
})
require.NoError(suite.t, err)
suite.Equal(&protos.TableSchema{
require.Equal(suite.t, &protos.TableSchema{
TableIdentifier: tableName,
Columns: map[string]string{
"id": string(qvalue.QValueKindInt32),
Expand Down Expand Up @@ -157,7 +154,7 @@ func (suite PostgresSchemaDeltaTestSuite) TestAddAllColumnTypes() {
TableIdentifiers: []string{tableName},
})
require.NoError(suite.t, err)
suite.Equal(expectedTableSchema, output.TableNameSchemaMapping[tableName])
require.Equal(suite.t, expectedTableSchema, output.TableNameSchemaMapping[tableName])
}

func (suite PostgresSchemaDeltaTestSuite) TestAddTrickyColumnNames() {
Expand Down Expand Up @@ -203,7 +200,7 @@ func (suite PostgresSchemaDeltaTestSuite) TestAddTrickyColumnNames() {
TableIdentifiers: []string{tableName},
})
require.NoError(suite.t, err)
suite.Equal(expectedTableSchema, output.TableNameSchemaMapping[tableName])
require.Equal(suite.t, expectedTableSchema, output.TableNameSchemaMapping[tableName])
}

func (suite PostgresSchemaDeltaTestSuite) TestAddDropWhitespaceColumnNames() {
Expand Down Expand Up @@ -243,7 +240,7 @@ func (suite PostgresSchemaDeltaTestSuite) TestAddDropWhitespaceColumnNames() {
TableIdentifiers: []string{tableName},
})
require.NoError(suite.t, err)
suite.Equal(expectedTableSchema, output.TableNameSchemaMapping[tableName])
require.Equal(suite.t, expectedTableSchema, output.TableNameSchemaMapping[tableName])
}

func TestPostgresSchemaDeltaTestSuite(t *testing.T) {
Expand Down
14 changes: 6 additions & 8 deletions flow/e2e/bigquery/peer_flow_bq_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import (
)

type PeerFlowE2ETestSuiteBQ struct {
got.G
t *testing.T

bqSuffix string
Expand Down Expand Up @@ -102,7 +101,7 @@ func setupBigQuery(t *testing.T) *BigQueryTestHelper {
}

// Implement SetupAllSuite interface to setup the test suite
func setupSuite(t *testing.T, g got.G) PeerFlowE2ETestSuiteBQ {
func setupSuite(t *testing.T) PeerFlowE2ETestSuiteBQ {
err := godotenv.Load()
if err != nil {
// it's okay if the .env file is not present
Expand All @@ -122,7 +121,6 @@ func setupSuite(t *testing.T, g got.G) PeerFlowE2ETestSuiteBQ {
bq := setupBigQuery(t)

return PeerFlowE2ETestSuiteBQ{
G: g,
t: t,
bqSuffix: bqSuffix,
pool: pool,
Expand All @@ -134,13 +132,13 @@ func (s PeerFlowE2ETestSuiteBQ) TearDownSuite() {
err := e2e.TearDownPostgres(s.pool, s.bqSuffix)
if err != nil {
slog.Error("failed to tear down postgres", slog.Any("error", err))
s.FailNow()
s.t.FailNow()
}

err = s.bqHelper.DropDataset()
if err != nil {
slog.Error("failed to tear down bigquery", slog.Any("error", err))
s.FailNow()
s.t.FailNow()
}
}

Expand Down Expand Up @@ -316,7 +314,7 @@ func (s PeerFlowE2ETestSuiteBQ) Test_Complete_Simple_Flow_BQ() {

count, err := s.bqHelper.countRows(dstTableName)
require.NoError(s.t, err)
s.Equal(10, count)
require.Equal(s.t, 10, count)

// TODO: verify that the data is correctly synced to the destination table
// on the bigquery side
Expand Down Expand Up @@ -798,8 +796,8 @@ func (s PeerFlowE2ETestSuiteBQ) Test_Multi_Table_BQ() {
count2, err := s.bqHelper.countRows(dstTable2Name)
require.NoError(s.t, err)

s.Equal(1, count1)
s.Equal(1, count2)
require.Equal(s.t, 1, count1)
require.Equal(s.t, 1, count2)

env.AssertExpectations(s.t)
}
Expand Down
4 changes: 1 addition & 3 deletions flow/e2e/postgres/qrep_flow_pg_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import (
)

type PeerFlowE2ETestSuitePG struct {
got.G
t *testing.T

pool *pgxpool.Pool
Expand All @@ -33,7 +32,7 @@ func TestPeerFlowE2ETestSuitePG(t *testing.T) {
got.Each(t, e2eshared.GotSuite(setupSuite))
}

func setupSuite(t *testing.T, g got.G) PeerFlowE2ETestSuitePG {
func setupSuite(t *testing.T) PeerFlowE2ETestSuitePG {
err := godotenv.Load()
if err != nil {
// it's okay if the .env file is not present
Expand All @@ -59,7 +58,6 @@ func setupSuite(t *testing.T, g got.G) PeerFlowE2ETestSuitePG {
}, false)
require.NoError(t, err)
return PeerFlowE2ETestSuitePG{
G: g,
t: t,
pool: pool,
peer: peer,
Expand Down
4 changes: 1 addition & 3 deletions flow/e2e/s3/qrep_flow_s3_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import (
)

type PeerFlowE2ETestSuiteS3 struct {
got.G
t *testing.T

pool *pgxpool.Pool
Expand All @@ -41,7 +40,7 @@ func setupS3(mode string) (*S3TestHelper, error) {
return NewS3TestHelper(mode == "gcs")
}

func setupSuite(t *testing.T, g got.G) PeerFlowE2ETestSuiteS3 {
func setupSuite(t *testing.T) PeerFlowE2ETestSuiteS3 {
err := godotenv.Load()
if err != nil {
// it's okay if the .env file is not present
Expand All @@ -61,7 +60,6 @@ func setupSuite(t *testing.T, g got.G) PeerFlowE2ETestSuiteS3 {
}

return PeerFlowE2ETestSuiteS3{
G: g,
t: t,
pool: pool,
s3Helper: helper,
Expand Down
Loading

0 comments on commit 9212271

Please sign in to comment.