Skip to content

Commit

Permalink
Remove use of got.G (#960)
Browse files Browse the repository at this point in the history
got.G only introduces methods which align to testify/assert rather than testify/require
  • Loading branch information
serprex authored Jan 2, 2024
1 parent fcfa74c commit d3c23f8
Show file tree
Hide file tree
Showing 12 changed files with 152 additions and 183 deletions.
13 changes: 5 additions & 8 deletions flow/connectors/postgres/postgres_schema_delta_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,15 @@ import (
"github.com/PeerDB-io/peer-flow/shared"
"github.com/jackc/pgx/v5"
"github.com/stretchr/testify/require"
"github.com/ysmood/got"
)

type PostgresSchemaDeltaTestSuite struct {
got.G
t *testing.T
connector *PostgresConnector
schema string
}

func SetupSuite(t *testing.T, g got.G) PostgresSchemaDeltaTestSuite {
func SetupSuite(t *testing.T) PostgresSchemaDeltaTestSuite {
t.Helper()

connector, err := NewPostgresConnector(context.Background(), &protos.PostgresConfig{
Expand Down Expand Up @@ -53,7 +51,6 @@ func SetupSuite(t *testing.T, g got.G) PostgresSchemaDeltaTestSuite {
require.NoError(t, err)

return PostgresSchemaDeltaTestSuite{
G: g,
t: t,
connector: connector,
schema: schema,
Expand All @@ -80,7 +77,7 @@ func (s PostgresSchemaDeltaTestSuite) TestSimpleAddColumn() {
TableIdentifiers: []string{tableName},
})
require.NoError(s.t, err)
s.Equal(&protos.TableSchema{
require.Equal(s.t, &protos.TableSchema{
TableIdentifier: tableName,
ColumnNames: []string{"id", "hi"},
ColumnTypes: []string{string(qvalue.QValueKindInt32), string(qvalue.QValueKindInt64)},
Expand Down Expand Up @@ -143,7 +140,7 @@ func (s PostgresSchemaDeltaTestSuite) TestAddAllColumnTypes() {
TableIdentifiers: []string{tableName},
})
require.NoError(s.t, err)
s.Equal(expectedTableSchema, output.TableNameSchemaMapping[tableName])
require.Equal(s.t, expectedTableSchema, output.TableNameSchemaMapping[tableName])
}

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

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

func TestPostgresSchemaDeltaTestSuite(t *testing.T) {
Expand Down
67 changes: 32 additions & 35 deletions flow/e2e/bigquery/peer_flow_bq_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,9 @@ import (
"github.com/jackc/pgx/v5/pgxpool"
"github.com/joho/godotenv"
"github.com/stretchr/testify/require"
"github.com/ysmood/got"
)

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

bqSuffix string
Expand All @@ -35,13 +33,13 @@ func TestPeerFlowE2ETestSuiteBQ(t *testing.T) {
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(s.bqHelper.datasetName)
if err != nil {
slog.Error("failed to tear down bigquery", slog.Any("error", err))
s.FailNow()
s.t.FailNow()
}
})
}
Expand Down Expand Up @@ -118,7 +116,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 {
t.Helper()

err := godotenv.Load()
Expand All @@ -140,7 +138,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 @@ -161,7 +158,7 @@ func (s PeerFlowE2ETestSuiteBQ) Test_Invalid_Connection_Config() {
env.ExecuteWorkflow(peerflow.CDCFlowWorkflowWithConfig, nil, &limits, nil)

// Verify workflow completes
s.True(env.IsWorkflowCompleted())
require.True(s.t, env.IsWorkflowCompleted())
err := env.GetWorkflowError()

// assert that error contains "invalid connection configs"
Expand Down Expand Up @@ -205,7 +202,7 @@ func (s PeerFlowE2ETestSuiteBQ) Test_Complete_Flow_No_Data() {
env.ExecuteWorkflow(peerflow.CDCFlowWorkflowWithConfig, flowConnConfig, &limits, nil)

// Verify workflow completes without error
s.True(env.IsWorkflowCompleted())
require.True(s.t, env.IsWorkflowCompleted())
err = env.GetWorkflowError()

// allow only continue as new error
Expand Down Expand Up @@ -249,7 +246,7 @@ func (s PeerFlowE2ETestSuiteBQ) Test_Char_ColType_Error() {
env.ExecuteWorkflow(peerflow.CDCFlowWorkflowWithConfig, flowConnConfig, &limits, nil)

// Verify workflow completes without error
s.True(env.IsWorkflowCompleted())
require.True(s.t, env.IsWorkflowCompleted())
err = env.GetWorkflowError()

// allow only continue as new error
Expand Down Expand Up @@ -312,15 +309,15 @@ func (s PeerFlowE2ETestSuiteBQ) Test_Complete_Simple_Flow_BQ() {
env.ExecuteWorkflow(peerflow.CDCFlowWorkflowWithConfig, flowConnConfig, &limits, nil)

// Verify workflow completes without error
s.True(env.IsWorkflowCompleted())
require.True(s.t, env.IsWorkflowCompleted())
err = env.GetWorkflowError()

// allow only continue as new error
require.Contains(s.t, err.Error(), "continue as new")

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 @@ -386,7 +383,7 @@ func (s PeerFlowE2ETestSuiteBQ) Test_Toast_BQ() {
env.ExecuteWorkflow(peerflow.CDCFlowWorkflowWithConfig, flowConnConfig, &limits, nil)

// Verify workflow completes without error
s.True(env.IsWorkflowCompleted())
require.True(s.t, env.IsWorkflowCompleted())
err = env.GetWorkflowError()

// allow only continue as new error
Expand Down Expand Up @@ -449,7 +446,7 @@ func (s PeerFlowE2ETestSuiteBQ) Test_Toast_Nochanges_BQ() {
env.ExecuteWorkflow(peerflow.CDCFlowWorkflowWithConfig, flowConnConfig, &limits, nil)

// Verify workflow completes without error
s.True(env.IsWorkflowCompleted())
require.True(s.t, env.IsWorkflowCompleted())
err = env.GetWorkflowError()

// allow only continue as new error
Expand Down Expand Up @@ -524,7 +521,7 @@ func (s PeerFlowE2ETestSuiteBQ) Test_Toast_Advance_1_BQ() {
env.ExecuteWorkflow(peerflow.CDCFlowWorkflowWithConfig, flowConnConfig, &limits, nil)

// Verify workflow completes without error
s.True(env.IsWorkflowCompleted())
require.True(s.t, env.IsWorkflowCompleted())
err = env.GetWorkflowError()

// allow only continue as new error
Expand Down Expand Up @@ -591,7 +588,7 @@ func (s PeerFlowE2ETestSuiteBQ) Test_Toast_Advance_2_BQ() {
env.ExecuteWorkflow(peerflow.CDCFlowWorkflowWithConfig, flowConnConfig, &limits, nil)

// Verify workflow completes without error
s.True(env.IsWorkflowCompleted())
require.True(s.t, env.IsWorkflowCompleted())
err = env.GetWorkflowError()

// allow only continue as new error
Expand Down Expand Up @@ -658,7 +655,7 @@ func (s PeerFlowE2ETestSuiteBQ) Test_Toast_Advance_3_BQ() {
env.ExecuteWorkflow(peerflow.CDCFlowWorkflowWithConfig, flowConnConfig, &limits, nil)

// Verify workflow completes without error
s.True(env.IsWorkflowCompleted())
require.True(s.t, env.IsWorkflowCompleted())
err = env.GetWorkflowError()

// allow only continue as new error
Expand Down Expand Up @@ -726,7 +723,7 @@ func (s PeerFlowE2ETestSuiteBQ) Test_Types_BQ() {
env.ExecuteWorkflow(peerflow.CDCFlowWorkflowWithConfig, flowConnConfig, &limits, nil)

// Verify workflow completes without error
s.True(env.IsWorkflowCompleted())
require.True(s.t, env.IsWorkflowCompleted())
err = env.GetWorkflowError()

// allow only continue as new error
Expand All @@ -742,7 +739,7 @@ func (s PeerFlowE2ETestSuiteBQ) Test_Types_BQ() {
s.t.Log(err)
}
// Make sure that there are no nulls
s.True(noNulls)
require.True(s.t, noNulls)

env.AssertExpectations(s.t)
}
Expand Down Expand Up @@ -802,8 +799,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 Expand Up @@ -900,7 +897,7 @@ func (s PeerFlowE2ETestSuiteBQ) Test_Simple_Schema_Changes_BQ() {
env.ExecuteWorkflow(peerflow.CDCFlowWorkflowWithConfig, flowConnConfig, &limits, nil)

// Verify workflow completes without error
s.True(env.IsWorkflowCompleted())
require.True(s.t, env.IsWorkflowCompleted())
err = env.GetWorkflowError()

// allow only continue as new error
Expand Down Expand Up @@ -971,7 +968,7 @@ func (s PeerFlowE2ETestSuiteBQ) Test_Composite_PKey_BQ() {
env.ExecuteWorkflow(peerflow.CDCFlowWorkflowWithConfig, flowConnConfig, &limits, nil)

// Verify workflow completes without error
s.True(env.IsWorkflowCompleted())
require.True(s.t, env.IsWorkflowCompleted())
err = env.GetWorkflowError()

// allow only continue as new error
Expand Down Expand Up @@ -1047,7 +1044,7 @@ func (s PeerFlowE2ETestSuiteBQ) Test_Composite_PKey_Toast_1_BQ() {
env.ExecuteWorkflow(peerflow.CDCFlowWorkflowWithConfig, flowConnConfig, &limits, nil)

// Verify workflow completes without error
s.True(env.IsWorkflowCompleted())
require.True(s.t, env.IsWorkflowCompleted())
err = env.GetWorkflowError()

// allow only continue as new error
Expand Down Expand Up @@ -1120,7 +1117,7 @@ func (s PeerFlowE2ETestSuiteBQ) Test_Composite_PKey_Toast_2_BQ() {
env.ExecuteWorkflow(peerflow.CDCFlowWorkflowWithConfig, flowConnConfig, &limits, nil)

// Verify workflow completes without error
s.True(env.IsWorkflowCompleted())
require.True(s.t, env.IsWorkflowCompleted())
err = env.GetWorkflowError()

// allow only continue as new error
Expand Down Expand Up @@ -1183,7 +1180,7 @@ func (s PeerFlowE2ETestSuiteBQ) Test_Columns_BQ() {
env.ExecuteWorkflow(peerflow.CDCFlowWorkflowWithConfig, flowConnConfig, &limits, nil)

// Verify workflow completes without error
s.True(env.IsWorkflowCompleted())
require.True(s.t, env.IsWorkflowCompleted())
err = env.GetWorkflowError()

// allow only continue as new error
Expand Down Expand Up @@ -1254,8 +1251,8 @@ func (s PeerFlowE2ETestSuiteBQ) Test_Multi_Table_Multi_Dataset_BQ() {
count2, err := s.bqHelper.countRowsWithDataset(secondDataset, 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)

err = s.bqHelper.DropDataset(secondDataset)
require.NoError(s.t, err)
Expand Down Expand Up @@ -1334,7 +1331,7 @@ func (s PeerFlowE2ETestSuiteBQ) Test_Soft_Delete_Basic() {
}()

env.ExecuteWorkflow(peerflow.CDCFlowWorkflowWithConfig, config, &limits, nil)
s.True(env.IsWorkflowCompleted())
require.True(s.t, env.IsWorkflowCompleted())
err = env.GetWorkflowError()
require.Contains(s.t, err.Error(), "continue as new")

Expand All @@ -1348,7 +1345,7 @@ func (s PeerFlowE2ETestSuiteBQ) Test_Soft_Delete_Basic() {
s.bqHelper.datasetName, dstTableName)
numNewRows, err := s.bqHelper.RunInt64Query(newerSyncedAtQuery)
require.NoError(s.t, err)
s.Eq(1, numNewRows)
require.Equal(s.t, int64(1), numNewRows)
}

func (s PeerFlowE2ETestSuiteBQ) Test_Soft_Delete_IUD_Same_Batch() {
Expand Down Expand Up @@ -1420,7 +1417,7 @@ func (s PeerFlowE2ETestSuiteBQ) Test_Soft_Delete_IUD_Same_Batch() {
}()

env.ExecuteWorkflow(peerflow.CDCFlowWorkflowWithConfig, config, &limits, nil)
s.True(env.IsWorkflowCompleted())
require.True(s.t, env.IsWorkflowCompleted())
err = env.GetWorkflowError()
require.Contains(s.t, err.Error(), "continue as new")

Expand All @@ -1432,7 +1429,7 @@ func (s PeerFlowE2ETestSuiteBQ) Test_Soft_Delete_IUD_Same_Batch() {
s.bqHelper.datasetName, dstTableName)
numNewRows, err := s.bqHelper.RunInt64Query(newerSyncedAtQuery)
require.NoError(s.t, err)
s.Eq(1, numNewRows)
require.Equal(s.t, int64(1), numNewRows)
}

func (s PeerFlowE2ETestSuiteBQ) Test_Soft_Delete_UD_Same_Batch() {
Expand Down Expand Up @@ -1508,7 +1505,7 @@ func (s PeerFlowE2ETestSuiteBQ) Test_Soft_Delete_UD_Same_Batch() {
}()

env.ExecuteWorkflow(peerflow.CDCFlowWorkflowWithConfig, config, &limits, nil)
s.True(env.IsWorkflowCompleted())
require.True(s.t, env.IsWorkflowCompleted())
err = env.GetWorkflowError()
require.Contains(s.t, err.Error(), "continue as new")

Expand All @@ -1520,7 +1517,7 @@ func (s PeerFlowE2ETestSuiteBQ) Test_Soft_Delete_UD_Same_Batch() {
s.bqHelper.datasetName, dstTableName)
numNewRows, err := s.bqHelper.RunInt64Query(newerSyncedAtQuery)
require.NoError(s.t, err)
s.Eq(1, numNewRows)
require.Equal(s.t, int64(1), numNewRows)
}

func (s PeerFlowE2ETestSuiteBQ) Test_Soft_Delete_Insert_After_Delete() {
Expand Down Expand Up @@ -1584,7 +1581,7 @@ func (s PeerFlowE2ETestSuiteBQ) Test_Soft_Delete_Insert_After_Delete() {
}()

env.ExecuteWorkflow(peerflow.CDCFlowWorkflowWithConfig, config, &limits, nil)
s.True(env.IsWorkflowCompleted())
require.True(s.t, env.IsWorkflowCompleted())
err = env.GetWorkflowError()
require.Contains(s.t, err.Error(), "continue as new")

Expand All @@ -1596,5 +1593,5 @@ func (s PeerFlowE2ETestSuiteBQ) Test_Soft_Delete_Insert_After_Delete() {
s.bqHelper.datasetName, dstTableName)
numNewRows, err := s.bqHelper.RunInt64Query(newerSyncedAtQuery)
require.NoError(s.t, err)
s.Eq(0, numNewRows)
require.Equal(s.t, int64(0), numNewRows)
}
4 changes: 2 additions & 2 deletions flow/e2e/bigquery/qrep_flow_bq_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ func (s PeerFlowE2ETestSuiteBQ) Test_Complete_QRep_Flow_Avro() {
e2e.RunQrepFlowWorkflow(env, qrepConfig)

// Verify workflow completes without error
s.True(env.IsWorkflowCompleted())
require.True(s.t, env.IsWorkflowCompleted())

err = env.GetWorkflowError()
require.NoError(s.t, err)
Expand Down Expand Up @@ -105,7 +105,7 @@ func (s PeerFlowE2ETestSuiteBQ) Test_PeerDB_Columns_QRep_BQ() {
e2e.RunQrepFlowWorkflow(env, qrepConfig)

// Verify workflow completes without error
s.True(env.IsWorkflowCompleted())
require.True(s.t, env.IsWorkflowCompleted())

err = env.GetWorkflowError()
require.NoError(s.t, err)
Expand Down
Loading

0 comments on commit d3c23f8

Please sign in to comment.