From 0e01a67a33121cceca4068cbda83c723c5cb9df6 Mon Sep 17 00:00:00 2001 From: Roy Crihfield Date: Sun, 6 Aug 2023 13:05:46 +0800 Subject: [PATCH] rm redundant functions --- indexer/database/sql/postgres/pgx_test.go | 10 ++-------- indexer/database/sql/postgres/sqlx_test.go | 4 ++-- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/indexer/database/sql/postgres/pgx_test.go b/indexer/database/sql/postgres/pgx_test.go index 5dff430..7b01502 100644 --- a/indexer/database/sql/postgres/pgx_test.go +++ b/indexer/database/sql/postgres/pgx_test.go @@ -36,12 +36,6 @@ var ( ctx = context.Background() ) -func expectContainsSubstring(t *testing.T, full string, sub string) { - if !strings.Contains(full, sub) { - t.Fatalf("Expected \"%v\" to contain substring \"%v\"\n", full, sub) - } -} - func TestPostgresPGX(t *testing.T) { t.Run("connects to the sql", func(t *testing.T) { dbPool, err := pgxpool.ConnectConfig(context.Background(), pgxConfig) @@ -105,7 +99,7 @@ func TestPostgresPGX(t *testing.T) { t.Fatal("Expected an error") } - expectContainsSubstring(t, err.Error(), postgres.DbConnectionFailedMsg) + require.Contains(t, err.Error(), postgres.DbConnectionFailedMsg) }) t.Run("throws error when can't create node", func(t *testing.T) { @@ -117,6 +111,6 @@ func TestPostgresPGX(t *testing.T) { t.Fatal("Expected an error") } - expectContainsSubstring(t, err.Error(), postgres.SettingNodeFailedMsg) + require.Contains(t, err.Error(), postgres.SettingNodeFailedMsg) }) } diff --git a/indexer/database/sql/postgres/sqlx_test.go b/indexer/database/sql/postgres/sqlx_test.go index 28f4473..f9bd2bd 100644 --- a/indexer/database/sql/postgres/sqlx_test.go +++ b/indexer/database/sql/postgres/sqlx_test.go @@ -102,7 +102,7 @@ func TestPostgresSQLX(t *testing.T) { t.Fatal("Expected an error") } - expectContainsSubstring(t, err.Error(), postgres.DbConnectionFailedMsg) + require.Contains(t, err.Error(), postgres.DbConnectionFailedMsg) }) t.Run("throws error when can't create node", func(t *testing.T) { @@ -114,6 +114,6 @@ func TestPostgresSQLX(t *testing.T) { t.Fatal("Expected an error") } - expectContainsSubstring(t, err.Error(), postgres.SettingNodeFailedMsg) + require.Contains(t, err.Error(), postgres.SettingNodeFailedMsg) }) }