Skip to content

Commit

Permalink
chore: use env line separator
Browse files Browse the repository at this point in the history
  • Loading branch information
olavloite committed Dec 1, 2024
1 parent 91ab4ef commit 812a3a7
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 46 deletions.
2 changes: 1 addition & 1 deletion .ci/e2e-expected/backslash-dt.txt
Original file line number Diff line number Diff line change
Expand Up @@ -79,5 +79,5 @@
testdb_e2e_psql_v?? | spanner_sys | txn_stats_total_10minute | VIEW | | | | | | | | | | | | |
testdb_e2e_psql_v?? | spanner_sys | txn_stats_total_hour | VIEW | | | | | | | | | | | | |
testdb_e2e_psql_v?? | spanner_sys | txn_stats_total_minute | VIEW | | | | | | | | | | | | |
(77 rows)
(78 rows)

53 changes: 27 additions & 26 deletions src/test/csharp/pgadapter_npgsql_tests/npgsql_tests/NpgsqlTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public void TestShowServerVersion()
while (reader.Read())
{
var version = reader.GetString(0);
Console.WriteLine($"{version}");
Console.Write($"{version}\n");
}
}
}
Expand All @@ -88,7 +88,7 @@ public void TestShowApplicationName()
while (reader.Read())
{
var applicationName = reader.GetString(0);
Console.WriteLine($"{applicationName}");
Console.Write($"{applicationName}\n");
}
}
}
Expand All @@ -113,7 +113,7 @@ public void TestSelect1()
return;
}
}
Console.WriteLine("Success");
Console.Write("Success\n");
}

public void TestSelectArray()
Expand All @@ -136,7 +136,7 @@ public void TestSelectArray()
return;
}
}
Console.WriteLine("Success");
Console.Write("Success\n");
}

public void TestQueryWithParameter()
Expand Down Expand Up @@ -165,7 +165,7 @@ public void TestQueryWithParameter()
return;
}
}
Console.WriteLine("Success");
Console.Write("Success\n");
}

public void TestQueryAllDataTypes()
Expand Down Expand Up @@ -245,7 +245,7 @@ public void TestQueryAllDataTypes()
}
}
}
Console.WriteLine("Success");
Console.Write("Success\n");
}

public void TestUpdateAllDataTypes()
Expand Down Expand Up @@ -279,7 +279,7 @@ public void TestUpdateAllDataTypes()
Console.WriteLine($"Update count mismatch. Got: {updateCount}, Want: 1");
return;
}
Console.WriteLine("Success");
Console.Write("Success\n");
}

public void TestInsertAllDataTypes()
Expand Down Expand Up @@ -313,7 +313,7 @@ public void TestInsertAllDataTypes()
Console.WriteLine($"Update count mismatch. Got: {updateCount}, Want: 1");
return;
}
Console.WriteLine("Success");
Console.Write("Success\n");
}

public void TestInsertNullsAllDataTypes()
Expand Down Expand Up @@ -348,7 +348,7 @@ public void TestInsertNullsAllDataTypes()
Console.WriteLine($"Update count mismatch. Got: {updateCount}, Want: 1");
return;
}
Console.WriteLine("Success");
Console.Write("Success\n");
}

public void TestInsertAllDataTypesReturning()
Expand Down Expand Up @@ -446,7 +446,7 @@ public void TestInsertAllDataTypesReturning()
}
}
}
Console.WriteLine("Success");
Console.Write("Success\n");
}

public void TestInsertBatch()
Expand Down Expand Up @@ -486,7 +486,7 @@ public void TestInsertBatch()
Console.WriteLine($"Update count mismatch. Got: {updateCount}, Want: {batchSize}");
return;
}
Console.WriteLine("Success");
Console.Write("Success\n");
}

public void TestMixedBatch()
Expand Down Expand Up @@ -572,7 +572,7 @@ public void TestMixedBatch()
return;
}
}
Console.WriteLine("Success");
Console.Write("Success\n");
}

public void TestBatchExecutionError()
Expand Down Expand Up @@ -609,7 +609,7 @@ public void TestBatchExecutionError()
try
{
var updateCount = batch.ExecuteNonQuery();
Console.WriteLine($"Update count: {updateCount}");
Console.Write($"Update count: {updateCount}\n");
}
catch (Exception exception)
{
Expand Down Expand Up @@ -683,7 +683,7 @@ constraint chk_end_time_after_start_time check (end_time > start_time)
Console.WriteLine($"Batch returned {updateCount} updates, expected -1.");
return;
}
Console.WriteLine("Success");
Console.Write("Success\n");
}

public void TestDdlScript()
Expand Down Expand Up @@ -757,7 +757,7 @@ constraint chk_end_time_after_start_time check (end_time > start_time)
Console.WriteLine($"Batch returned {updateCount} updates, expected -1.");
return;
}
Console.WriteLine("Success");
Console.Write("Success\n");
}

public void TestBinaryCopyIn()
Expand Down Expand Up @@ -799,7 +799,7 @@ public void TestBinaryCopyIn()
writer.Complete();
}

Console.WriteLine("Success");
Console.Write("Success\n");
}

public void TestTextCopyIn()
Expand Down Expand Up @@ -838,7 +838,7 @@ public void TestTextCopyIn()
writer.Write("\\N\n");
}

Console.WriteLine("Success");
Console.Write("Success\n");
}

public void TestBinaryCopyOut()
Expand Down Expand Up @@ -1085,7 +1085,7 @@ public void TestBinaryCopyOut()
Console.Write("\n");
}
}
Console.WriteLine("Success");
Console.Write("Success\n");
}

public void TestTextCopyOut()
Expand All @@ -1104,10 +1104,11 @@ public void TestTextCopyOut()
{
break;
}
Console.WriteLine(line);
Console.Write(line);
Console.Write("\n");
}
}
Console.WriteLine("Success");
Console.Write("Success\n");
}

public void TestSimplePrepare()
Expand All @@ -1118,7 +1119,7 @@ public void TestSimplePrepare()
var cmd = new NpgsqlCommand("SELECT * FROM all_types WHERE col_bigint=$1", connection);
cmd.Parameters.Add("param", NpgsqlDbType.Integer);
cmd.Prepare();
Console.WriteLine("Success");
Console.Write("Success\n");
}

public void TestPrepareAndExecute()
Expand Down Expand Up @@ -1168,7 +1169,7 @@ public void TestPrepareAndExecute()
return;
}
}
Console.WriteLine("Success");
Console.Write("Success\n");
}

public void TestReadWriteTransaction()
Expand All @@ -1185,7 +1186,7 @@ public void TestReadWriteTransaction()
{
while (reader.Read())
{
Console.WriteLine("Row: " + reader.GetInt64(0));
Console.Write("Row: " + reader.GetInt64(0) + "\n");
}
}
var insertSql =
Expand Down Expand Up @@ -1223,7 +1224,7 @@ public void TestReadWriteTransaction()
}
}
transaction.Commit();
Console.WriteLine("Success");
Console.Write("Success\n");
}

public void TestReadOnlyTransaction()
Expand All @@ -1242,12 +1243,12 @@ public void TestReadOnlyTransaction()
using var reader = selectCommand.ExecuteReader();
while (reader.Read())
{
Console.WriteLine("Row: " + reader.GetInt64(0));
Console.Write("Row: " + reader.GetInt64(0) + "\n");
}
}
// We need to either commit or rollback the transaction to release the underlying resources.
transaction.Commit();
Console.WriteLine("Success");
Console.Write("Success\n");
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -157,34 +157,40 @@ public void clearTestData() {
databaseId, Collections.singletonList(Mutation.delete("all_types", KeySet.all())));
}

static void assertEqualsIgnoreNewLines(String expected, String actual) {
expected = expected.replace("\n", "").replace("\r", "").replaceAll("\\p{C}", "");
actual = actual.replace("\n", "").replace("\r", "").replaceAll("\\p{C}", "");
assertEquals(expected, actual);
}

@Test
public void testShowServerVersion() throws IOException, InterruptedException {
String result = execute("TestShowServerVersion", createConnectionString());
assertEquals("14.1", result.trim());
assertEqualsIgnoreNewLines("14.1\n", result);
}

@Test
public void testSelect1() throws IOException, InterruptedException {
String result = execute("TestSelect1", createConnectionString());
assertEquals("Success", result.trim());
assertEqualsIgnoreNewLines("Success\n", result);
}

@Test
public void testSelectArray() throws IOException, InterruptedException {
String result = execute("TestSelectArray", createConnectionString());
assertEquals("Success", result.trim());
assertEqualsIgnoreNewLines("Success\n", result);
}

@Test
public void testQueryAllDataTypes() throws IOException, InterruptedException {
String result = execute("TestQueryAllDataTypes", createConnectionString());
assertEquals("Success", result.trim());
assertEqualsIgnoreNewLines("Success\n", result);
}

@Test
public void testUpdateAllDataTypes() throws IOException, InterruptedException {
String result = execute("TestUpdateAllDataTypes", createConnectionString());
assertEquals("Success", result.trim());
assertEqualsIgnoreNewLines("Success\n", result);
}

@Test
Expand All @@ -195,7 +201,7 @@ public void testInsertAllDataTypes() throws IOException, InterruptedException {
databaseId, Collections.singletonList(Mutation.delete("all_types", Key.of(100L))));

String result = execute("TestInsertAllDataTypes", createConnectionString());
assertEquals("Success", result.trim());
assertEqualsIgnoreNewLines("Success\n", result);
}

@Test
Expand All @@ -206,7 +212,7 @@ public void testInsertNullsAllDataTypes() throws IOException, InterruptedExcepti
databaseId, Collections.singletonList(Mutation.delete("all_types", Key.of(100L))));

String result = execute("TestInsertNullsAllDataTypes", createConnectionString());
assertEquals("Success", result.trim());
assertEqualsIgnoreNewLines("Success\n", result);
}

@Test
Expand All @@ -216,7 +222,7 @@ public void testInsertAllDataTypesReturning() throws IOException, InterruptedExc
testEnv.write(databaseId, Collections.singletonList(Mutation.delete("all_types", Key.of(1))));

String result = execute("TestInsertAllDataTypesReturning", createConnectionString());
assertEquals("Success", result.trim());
assertEqualsIgnoreNewLines("Success\n", result);
}

@Test
Expand All @@ -234,7 +240,7 @@ public void testInsertBatch() throws IOException, InterruptedException {
}

String result = execute("TestInsertBatch", createConnectionString());
assertEquals("Success", result.trim());
assertEquals("Success\n", result);

// Verify that we really received 10 rows.
final long batchSize = 10L;
Expand All @@ -261,7 +267,7 @@ public void testMixedBatch() throws IOException, InterruptedException {
}

String result = execute("TestMixedBatch", createConnectionString());
assertEquals("Success", result.trim());
assertEqualsIgnoreNewLines("Success\n", result);

final long batchSize = 5L;
try (ResultSet resultSet =
Expand Down Expand Up @@ -332,7 +338,7 @@ private void testCopyIn(String testMethod) throws IOException, InterruptedExcept
databaseId, Collections.singletonList(Mutation.delete("all_types", KeySet.all())));

String result = execute(testMethod, createConnectionString());
assertEquals("Success", result.trim());
assertEqualsIgnoreNewLines("Success\n", result);

DatabaseClient client = testEnv.getSpanner().getDatabaseClient(database.getId());
try (ResultSet resultSet =
Expand Down Expand Up @@ -372,23 +378,23 @@ public void testBinaryCopyOut() throws IOException, InterruptedException {
// Add an extra NULL-row to the table.
addNullRow();
String result = execute("TestBinaryCopyOut", createConnectionString());
assertEquals(
assertEqualsIgnoreNewLines(
"1\tTrue\tdGVzdA==\t3.14\t3.14\t100\t6.626\t20220216T131802123456\t20220329\ttest\t{\"key\": \"value\"}\t[1, , 2]\t[True, , False]\t[Ynl0ZXMx, , Ynl0ZXMy]\t[3.14, , -99.99]\t[3.14, , -99.99]\t[-100, , -200]\t[6.626, , -3.14]\t[20220216T161802123456, , 20000101T000000]\t[20230220, , 20000101]\t[string1, , string2]\t[{\"key\": \"value1\"}, , {\"key\": \"value2\"}]\n"
+ "2\tNULL\tNULL\tNULL\tNULL\tNULL\tNULL\tNULL\tNULL\tNULL\tNULL\tNULL\tNULL\tNULL\tNULL\tNULL\tNULL\tNULL\tNULL\tNULL\tNULL\tNULL\n"
+ "Success\n",
result.replace("\r", ""));
result);
}

@Test
public void testTextCopyOut() throws IOException, InterruptedException {
// Add an extra NULL-row to the table.
addNullRow();
String result = execute("TestTextCopyOut", createConnectionString());
assertEquals(
assertEqualsIgnoreNewLines(
"1\tt\t\\\\x74657374\t3.14\t3.14\t100\t6.626\t2022-02-16 14:18:02.123456+01\t2022-03-29\ttest\t{\"key\": \"value\"}\t{1,NULL,2}\t{t,NULL,f}\t{\"\\\\\\\\x627974657331\",NULL,\"\\\\\\\\x627974657332\"}\t{3.14,NULL,-99.99}\t{3.14,NULL,-99.99}\t{-100,NULL,-200}\t{6.626,NULL,-3.14}\t{\"2022-02-16 17:18:02.123456+01\",NULL,\"2000-01-01 01:00:00+01\"}\t{\"2023-02-20\",NULL,\"2000-01-01\"}\t{\"string1\",NULL,\"string2\"}\t{\"{\\\\\"key\\\\\": \\\\\"value1\\\\\"}\",NULL,\"{\\\\\"key\\\\\": \\\\\"value2\\\\\"}\"}\n"
+ "2\t\\N\t\\N\t\\N\t\\N\t\\N\t\\N\t\\N\t\\N\t\\N\t\\N\t\\N\t\\N\t\\N\t\\N\t\\N\t\\N\t\\N\t\\N\t\\N\t\\N\t\\N\n"
+ "Success\n",
result.replace("\r", ""));
result);
}

private void addNullRow() {
Expand Down Expand Up @@ -447,19 +453,19 @@ private void addNullRow() {
@Test
public void testSimplePrepare() throws IOException, InterruptedException {
String result = execute("TestSimplePrepare", createConnectionString());
assertEquals("Success", result.trim());
assertEqualsIgnoreNewLines("Success\n", result);
}

@Test
public void testPrepareAndExecute() throws IOException, InterruptedException {
String result = execute("TestPrepareAndExecute", createConnectionString());
assertEquals("Success", result.trim());
assertEqualsIgnoreNewLines("Success\n", result);
}

@Test
public void testReadWriteTransaction() throws IOException, InterruptedException {
String result = execute("TestReadWriteTransaction", createConnectionString());
assertEquals("Row: 1\n" + "Success\n", result.replace("\r", ""));
assertEquals("Row: 1\n" + "Success\n", result);
DatabaseClient client = testEnv.getSpanner().getDatabaseClient(database.getId());
try (ResultSet resultSet =
client.singleUse().executeQuery(Statement.of("SELECT COUNT(*) FROM all_types"))) {
Expand All @@ -472,6 +478,6 @@ public void testReadWriteTransaction() throws IOException, InterruptedException
@Test
public void testReadOnlyTransaction() throws IOException, InterruptedException {
String result = execute("TestReadOnlyTransaction", createConnectionString());
assertEquals("Row: 1\n" + "Row: 2\n" + "Success\n", result.replace("\r", ""));
assertEqualsIgnoreNewLines("Row: 1\n" + "Row: 2\n" + "Success\n", result);
}
}

0 comments on commit 812a3a7

Please sign in to comment.