From 01ff6aca459c033c14f5e40fe5c247191269abae Mon Sep 17 00:00:00 2001 From: Ryan Slade Date: Mon, 21 Oct 2024 11:26:46 +0200 Subject: [PATCH] Move pkg/testutils and pkg/jsonschema into internal (#418) I think moving these two packages should be pretty uncontroversial since they're used for testing and validation and we don't expect them to be imported others. Part of https://github.com/xataio/pgroll/issues/399 --- {pkg => internal}/jsonschema/jsonschema_test.go | 0 {pkg => internal}/jsonschema/testdata/add-column-1.txtar | 0 {pkg => internal}/jsonschema/testdata/alter-column-1.txtar | 0 {pkg => internal}/jsonschema/testdata/alter-column-2.txtar | 0 {pkg => internal}/jsonschema/testdata/alter-column-3.txtar | 0 {pkg => internal}/jsonschema/testdata/alter-column-4.txtar | 0 {pkg => internal}/jsonschema/testdata/alter-column-5.txtar | 0 {pkg => internal}/jsonschema/testdata/alter-column-6.txtar | 0 {pkg => internal}/jsonschema/testdata/alter-column-7.txtar | 0 {pkg => internal}/jsonschema/testdata/alter-column-8.txtar | 0 {pkg => internal}/jsonschema/testdata/alter-column-9.txtar | 0 {pkg => internal}/jsonschema/testdata/create-table-1.txtar | 0 .../jsonschema/testdata/rename-constraint-1.txtar | 0 {pkg => internal}/jsonschema/testdata/sql-1.txtar | 0 {pkg => internal}/jsonschema/testdata/sql-2.txtar | 0 {pkg => internal}/jsonschema/testdata/sql-3.txtar | 0 {pkg => internal}/jsonschema/testdata/sql-4.txtar | 0 {pkg => internal}/testutils/db.go | 0 {pkg => internal}/testutils/error_codes.go | 0 {pkg => internal}/testutils/sql_transformer.go | 0 {pkg => internal}/testutils/util.go | 1 + pkg/db/db_test.go | 3 ++- pkg/migrations/op_add_column_test.go | 2 +- pkg/migrations/op_alter_column_test.go | 3 ++- pkg/migrations/op_change_type_test.go | 3 ++- pkg/migrations/op_common_test.go | 3 ++- pkg/migrations/op_create_table_test.go | 6 +++--- pkg/migrations/op_drop_constraint_test.go | 3 ++- pkg/migrations/op_drop_not_null_test.go | 3 ++- pkg/migrations/op_raw_sql_test.go | 3 ++- pkg/migrations/op_set_check_test.go | 3 ++- pkg/migrations/op_set_fk_test.go | 3 ++- pkg/migrations/op_set_notnull_test.go | 3 ++- pkg/migrations/op_set_unique_test.go | 3 ++- pkg/roll/execute_test.go | 3 ++- pkg/state/state_test.go | 3 ++- 36 files changed, 31 insertions(+), 17 deletions(-) rename {pkg => internal}/jsonschema/jsonschema_test.go (100%) rename {pkg => internal}/jsonschema/testdata/add-column-1.txtar (100%) rename {pkg => internal}/jsonschema/testdata/alter-column-1.txtar (100%) rename {pkg => internal}/jsonschema/testdata/alter-column-2.txtar (100%) rename {pkg => internal}/jsonschema/testdata/alter-column-3.txtar (100%) rename {pkg => internal}/jsonschema/testdata/alter-column-4.txtar (100%) rename {pkg => internal}/jsonschema/testdata/alter-column-5.txtar (100%) rename {pkg => internal}/jsonschema/testdata/alter-column-6.txtar (100%) rename {pkg => internal}/jsonschema/testdata/alter-column-7.txtar (100%) rename {pkg => internal}/jsonschema/testdata/alter-column-8.txtar (100%) rename {pkg => internal}/jsonschema/testdata/alter-column-9.txtar (100%) rename {pkg => internal}/jsonschema/testdata/create-table-1.txtar (100%) rename {pkg => internal}/jsonschema/testdata/rename-constraint-1.txtar (100%) rename {pkg => internal}/jsonschema/testdata/sql-1.txtar (100%) rename {pkg => internal}/jsonschema/testdata/sql-2.txtar (100%) rename {pkg => internal}/jsonschema/testdata/sql-3.txtar (100%) rename {pkg => internal}/jsonschema/testdata/sql-4.txtar (100%) rename {pkg => internal}/testutils/db.go (100%) rename {pkg => internal}/testutils/error_codes.go (100%) rename {pkg => internal}/testutils/sql_transformer.go (100%) rename {pkg => internal}/testutils/util.go (99%) diff --git a/pkg/jsonschema/jsonschema_test.go b/internal/jsonschema/jsonschema_test.go similarity index 100% rename from pkg/jsonschema/jsonschema_test.go rename to internal/jsonschema/jsonschema_test.go diff --git a/pkg/jsonschema/testdata/add-column-1.txtar b/internal/jsonschema/testdata/add-column-1.txtar similarity index 100% rename from pkg/jsonschema/testdata/add-column-1.txtar rename to internal/jsonschema/testdata/add-column-1.txtar diff --git a/pkg/jsonschema/testdata/alter-column-1.txtar b/internal/jsonschema/testdata/alter-column-1.txtar similarity index 100% rename from pkg/jsonschema/testdata/alter-column-1.txtar rename to internal/jsonschema/testdata/alter-column-1.txtar diff --git a/pkg/jsonschema/testdata/alter-column-2.txtar b/internal/jsonschema/testdata/alter-column-2.txtar similarity index 100% rename from pkg/jsonschema/testdata/alter-column-2.txtar rename to internal/jsonschema/testdata/alter-column-2.txtar diff --git a/pkg/jsonschema/testdata/alter-column-3.txtar b/internal/jsonschema/testdata/alter-column-3.txtar similarity index 100% rename from pkg/jsonschema/testdata/alter-column-3.txtar rename to internal/jsonschema/testdata/alter-column-3.txtar diff --git a/pkg/jsonschema/testdata/alter-column-4.txtar b/internal/jsonschema/testdata/alter-column-4.txtar similarity index 100% rename from pkg/jsonschema/testdata/alter-column-4.txtar rename to internal/jsonschema/testdata/alter-column-4.txtar diff --git a/pkg/jsonschema/testdata/alter-column-5.txtar b/internal/jsonschema/testdata/alter-column-5.txtar similarity index 100% rename from pkg/jsonschema/testdata/alter-column-5.txtar rename to internal/jsonschema/testdata/alter-column-5.txtar diff --git a/pkg/jsonschema/testdata/alter-column-6.txtar b/internal/jsonschema/testdata/alter-column-6.txtar similarity index 100% rename from pkg/jsonschema/testdata/alter-column-6.txtar rename to internal/jsonschema/testdata/alter-column-6.txtar diff --git a/pkg/jsonschema/testdata/alter-column-7.txtar b/internal/jsonschema/testdata/alter-column-7.txtar similarity index 100% rename from pkg/jsonschema/testdata/alter-column-7.txtar rename to internal/jsonschema/testdata/alter-column-7.txtar diff --git a/pkg/jsonschema/testdata/alter-column-8.txtar b/internal/jsonschema/testdata/alter-column-8.txtar similarity index 100% rename from pkg/jsonschema/testdata/alter-column-8.txtar rename to internal/jsonschema/testdata/alter-column-8.txtar diff --git a/pkg/jsonschema/testdata/alter-column-9.txtar b/internal/jsonschema/testdata/alter-column-9.txtar similarity index 100% rename from pkg/jsonschema/testdata/alter-column-9.txtar rename to internal/jsonschema/testdata/alter-column-9.txtar diff --git a/pkg/jsonschema/testdata/create-table-1.txtar b/internal/jsonschema/testdata/create-table-1.txtar similarity index 100% rename from pkg/jsonschema/testdata/create-table-1.txtar rename to internal/jsonschema/testdata/create-table-1.txtar diff --git a/pkg/jsonschema/testdata/rename-constraint-1.txtar b/internal/jsonschema/testdata/rename-constraint-1.txtar similarity index 100% rename from pkg/jsonschema/testdata/rename-constraint-1.txtar rename to internal/jsonschema/testdata/rename-constraint-1.txtar diff --git a/pkg/jsonschema/testdata/sql-1.txtar b/internal/jsonschema/testdata/sql-1.txtar similarity index 100% rename from pkg/jsonschema/testdata/sql-1.txtar rename to internal/jsonschema/testdata/sql-1.txtar diff --git a/pkg/jsonschema/testdata/sql-2.txtar b/internal/jsonschema/testdata/sql-2.txtar similarity index 100% rename from pkg/jsonschema/testdata/sql-2.txtar rename to internal/jsonschema/testdata/sql-2.txtar diff --git a/pkg/jsonschema/testdata/sql-3.txtar b/internal/jsonschema/testdata/sql-3.txtar similarity index 100% rename from pkg/jsonschema/testdata/sql-3.txtar rename to internal/jsonschema/testdata/sql-3.txtar diff --git a/pkg/jsonschema/testdata/sql-4.txtar b/internal/jsonschema/testdata/sql-4.txtar similarity index 100% rename from pkg/jsonschema/testdata/sql-4.txtar rename to internal/jsonschema/testdata/sql-4.txtar diff --git a/pkg/testutils/db.go b/internal/testutils/db.go similarity index 100% rename from pkg/testutils/db.go rename to internal/testutils/db.go diff --git a/pkg/testutils/error_codes.go b/internal/testutils/error_codes.go similarity index 100% rename from pkg/testutils/error_codes.go rename to internal/testutils/error_codes.go diff --git a/pkg/testutils/sql_transformer.go b/internal/testutils/sql_transformer.go similarity index 100% rename from pkg/testutils/sql_transformer.go rename to internal/testutils/sql_transformer.go diff --git a/pkg/testutils/util.go b/internal/testutils/util.go similarity index 99% rename from pkg/testutils/util.go rename to internal/testutils/util.go index 29518eb5..465acbfd 100644 --- a/pkg/testutils/util.go +++ b/internal/testutils/util.go @@ -16,6 +16,7 @@ import ( "github.com/testcontainers/testcontainers-go" "github.com/testcontainers/testcontainers-go/modules/postgres" "github.com/testcontainers/testcontainers-go/wait" + "github.com/xataio/pgroll/pkg/roll" "github.com/xataio/pgroll/pkg/state" ) diff --git a/pkg/db/db_test.go b/pkg/db/db_test.go index bfc37b21..e89bbd93 100644 --- a/pkg/db/db_test.go +++ b/pkg/db/db_test.go @@ -9,9 +9,10 @@ import ( "testing" "time" + "github.com/xataio/pgroll/internal/testutils" + "github.com/stretchr/testify/require" "github.com/xataio/pgroll/pkg/db" - "github.com/xataio/pgroll/pkg/testutils" ) func TestMain(m *testing.M) { diff --git a/pkg/migrations/op_add_column_test.go b/pkg/migrations/op_add_column_test.go index 0a248053..5aa5f27d 100644 --- a/pkg/migrations/op_add_column_test.go +++ b/pkg/migrations/op_add_column_test.go @@ -8,9 +8,9 @@ import ( "github.com/stretchr/testify/assert" + "github.com/xataio/pgroll/internal/testutils" "github.com/xataio/pgroll/pkg/migrations" "github.com/xataio/pgroll/pkg/roll" - "github.com/xataio/pgroll/pkg/testutils" ) func TestAddColumn(t *testing.T) { diff --git a/pkg/migrations/op_alter_column_test.go b/pkg/migrations/op_alter_column_test.go index c8192ce4..b9428b2a 100644 --- a/pkg/migrations/op_alter_column_test.go +++ b/pkg/migrations/op_alter_column_test.go @@ -6,10 +6,11 @@ import ( "database/sql" "testing" + "github.com/xataio/pgroll/internal/testutils" + "github.com/oapi-codegen/nullable" "github.com/stretchr/testify/assert" "github.com/xataio/pgroll/pkg/migrations" - "github.com/xataio/pgroll/pkg/testutils" ) func TestAlterColumnMultipleSubOperations(t *testing.T) { diff --git a/pkg/migrations/op_change_type_test.go b/pkg/migrations/op_change_type_test.go index bf36e718..90b000fd 100644 --- a/pkg/migrations/op_change_type_test.go +++ b/pkg/migrations/op_change_type_test.go @@ -6,10 +6,11 @@ import ( "database/sql" "testing" + "github.com/xataio/pgroll/internal/testutils" + "github.com/stretchr/testify/assert" "github.com/xataio/pgroll/pkg/migrations" "github.com/xataio/pgroll/pkg/roll" - "github.com/xataio/pgroll/pkg/testutils" ) func TestChangeColumnType(t *testing.T) { diff --git a/pkg/migrations/op_common_test.go b/pkg/migrations/op_common_test.go index 01680d15..d3f573ab 100644 --- a/pkg/migrations/op_common_test.go +++ b/pkg/migrations/op_common_test.go @@ -11,10 +11,11 @@ import ( "slices" "testing" + "github.com/xataio/pgroll/internal/testutils" + "github.com/lib/pq" "github.com/xataio/pgroll/pkg/migrations" "github.com/xataio/pgroll/pkg/roll" - "github.com/xataio/pgroll/pkg/testutils" ) type TestCase struct { diff --git a/pkg/migrations/op_create_table_test.go b/pkg/migrations/op_create_table_test.go index daed86ca..25c73469 100644 --- a/pkg/migrations/op_create_table_test.go +++ b/pkg/migrations/op_create_table_test.go @@ -6,11 +6,11 @@ import ( "database/sql" "testing" + "github.com/stretchr/testify/assert" + + "github.com/xataio/pgroll/internal/testutils" "github.com/xataio/pgroll/pkg/migrations" "github.com/xataio/pgroll/pkg/roll" - "github.com/xataio/pgroll/pkg/testutils" - - "github.com/stretchr/testify/assert" ) func TestCreateTable(t *testing.T) { diff --git a/pkg/migrations/op_drop_constraint_test.go b/pkg/migrations/op_drop_constraint_test.go index da58cafa..2e1d359a 100644 --- a/pkg/migrations/op_drop_constraint_test.go +++ b/pkg/migrations/op_drop_constraint_test.go @@ -6,9 +6,10 @@ import ( "database/sql" "testing" + "github.com/xataio/pgroll/internal/testutils" + "github.com/stretchr/testify/assert" "github.com/xataio/pgroll/pkg/migrations" - "github.com/xataio/pgroll/pkg/testutils" ) func TestDropConstraint(t *testing.T) { diff --git a/pkg/migrations/op_drop_not_null_test.go b/pkg/migrations/op_drop_not_null_test.go index 446a7adf..f82822ee 100644 --- a/pkg/migrations/op_drop_not_null_test.go +++ b/pkg/migrations/op_drop_not_null_test.go @@ -6,9 +6,10 @@ import ( "database/sql" "testing" + "github.com/xataio/pgroll/internal/testutils" + "github.com/stretchr/testify/assert" "github.com/xataio/pgroll/pkg/migrations" - "github.com/xataio/pgroll/pkg/testutils" ) func TestDropNotNull(t *testing.T) { diff --git a/pkg/migrations/op_raw_sql_test.go b/pkg/migrations/op_raw_sql_test.go index c6f4e393..b134dc8d 100644 --- a/pkg/migrations/op_raw_sql_test.go +++ b/pkg/migrations/op_raw_sql_test.go @@ -6,9 +6,10 @@ import ( "database/sql" "testing" + "github.com/xataio/pgroll/internal/testutils" + "github.com/xataio/pgroll/pkg/migrations" "github.com/xataio/pgroll/pkg/roll" - "github.com/xataio/pgroll/pkg/testutils" ) func TestRawSQL(t *testing.T) { diff --git a/pkg/migrations/op_set_check_test.go b/pkg/migrations/op_set_check_test.go index 602fc806..c6ddbfbb 100644 --- a/pkg/migrations/op_set_check_test.go +++ b/pkg/migrations/op_set_check_test.go @@ -6,9 +6,10 @@ import ( "database/sql" "testing" + "github.com/xataio/pgroll/internal/testutils" + "github.com/stretchr/testify/assert" "github.com/xataio/pgroll/pkg/migrations" - "github.com/xataio/pgroll/pkg/testutils" ) func TestSetCheckConstraint(t *testing.T) { diff --git a/pkg/migrations/op_set_fk_test.go b/pkg/migrations/op_set_fk_test.go index 665048ed..1da01852 100644 --- a/pkg/migrations/op_set_fk_test.go +++ b/pkg/migrations/op_set_fk_test.go @@ -6,9 +6,10 @@ import ( "database/sql" "testing" + "github.com/xataio/pgroll/internal/testutils" + "github.com/stretchr/testify/assert" "github.com/xataio/pgroll/pkg/migrations" - "github.com/xataio/pgroll/pkg/testutils" ) func TestSetForeignKey(t *testing.T) { diff --git a/pkg/migrations/op_set_notnull_test.go b/pkg/migrations/op_set_notnull_test.go index 87cc3390..c4bc22e2 100644 --- a/pkg/migrations/op_set_notnull_test.go +++ b/pkg/migrations/op_set_notnull_test.go @@ -8,7 +8,8 @@ import ( "github.com/stretchr/testify/assert" "github.com/xataio/pgroll/pkg/migrations" - "github.com/xataio/pgroll/pkg/testutils" + + "github.com/xataio/pgroll/internal/testutils" ) func TestSetNotNull(t *testing.T) { diff --git a/pkg/migrations/op_set_unique_test.go b/pkg/migrations/op_set_unique_test.go index 2b05a519..34c3a568 100644 --- a/pkg/migrations/op_set_unique_test.go +++ b/pkg/migrations/op_set_unique_test.go @@ -7,8 +7,9 @@ import ( "testing" "github.com/stretchr/testify/assert" + + "github.com/xataio/pgroll/internal/testutils" "github.com/xataio/pgroll/pkg/migrations" - "github.com/xataio/pgroll/pkg/testutils" ) func TestSetColumnUnique(t *testing.T) { diff --git a/pkg/roll/execute_test.go b/pkg/roll/execute_test.go index 9227e362..6322ad01 100644 --- a/pkg/roll/execute_test.go +++ b/pkg/roll/execute_test.go @@ -11,10 +11,11 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + + "github.com/xataio/pgroll/internal/testutils" "github.com/xataio/pgroll/pkg/migrations" "github.com/xataio/pgroll/pkg/roll" "github.com/xataio/pgroll/pkg/state" - "github.com/xataio/pgroll/pkg/testutils" ) const ( diff --git a/pkg/state/state_test.go b/pkg/state/state_test.go index dab1049e..e5f48aca 100644 --- a/pkg/state/state_test.go +++ b/pkg/state/state_test.go @@ -14,10 +14,11 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + + "github.com/xataio/pgroll/internal/testutils" "github.com/xataio/pgroll/pkg/migrations" "github.com/xataio/pgroll/pkg/schema" "github.com/xataio/pgroll/pkg/state" - "github.com/xataio/pgroll/pkg/testutils" ) func TestMain(m *testing.M) {