Skip to content

Commit 5d5f0cb

Browse files
committed
add t.Log in integration test
1 parent 7b51aba commit 5d5f0cb

1 file changed

Lines changed: 7 additions & 8 deletions

File tree

internal/impl/gcp/enterprise/bigquery/integration_test.go

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ func TestIntegrationBigQueryWriteAPI(t *testing.T) {
4040
tableID = "test_table"
4141
)
4242

43-
// Start BigQuery emulator. Port 9050 = HTTP (BigQuery API),
44-
// port 9060 = gRPC (Storage Write API).
43+
// Given a BigQuery emulator with an empty table.
44+
t.Log("Given a BigQuery emulator running with HTTP and gRPC ports")
4545
ctr, err := testcontainers.Run(t.Context(),
4646
"ghcr.io/goccy/bigquery-emulator:latest",
4747
testcontainers.WithExposedPorts("9050/tcp", "9060/tcp"),
@@ -69,8 +69,7 @@ func TestIntegrationBigQueryWriteAPI(t *testing.T) {
6969
httpEndpoint := fmt.Sprintf("http://localhost:%s", httpPort.Port())
7070
grpcEndpoint := fmt.Sprintf("localhost:%s", grpcPort.Port())
7171

72-
// Create a table via the BigQuery HTTP API so the output has a schema to
73-
// fetch when creating its managed stream.
72+
t.Log("Given a table with name and age columns")
7473
bqClient, err := bigquery.NewClient(t.Context(), projectID,
7574
option.WithoutAuthentication(),
7675
option.WithEndpoint(httpEndpoint),
@@ -87,7 +86,8 @@ func TestIntegrationBigQueryWriteAPI(t *testing.T) {
8786
})
8887
require.NoError(t, err)
8988

90-
// Build a stream that produces messages into the BigQuery output.
89+
// When we build a stream with the BigQuery Write API output and send messages.
90+
t.Log("When we send 3 JSON messages through the BigQuery Write API output")
9191
sb := service.NewStreamBuilder()
9292
require.NoError(t, sb.SetLoggerYAML(`level: DEBUG`))
9393

@@ -118,8 +118,6 @@ gcp_bigquery_write_api:
118118
require.NoError(t, stream.StopWithin(10*time.Second))
119119
})
120120

121-
// Send test messages. int64 fields are encoded as strings per proto3
122-
// JSON mapping.
123121
for i, msg := range []string{
124122
`{"name":"alice","age":"30"}`,
125123
`{"name":"bob","age":"25"}`,
@@ -128,7 +126,8 @@ gcp_bigquery_write_api:
128126
require.NoError(t, sendFn(t.Context(), service.NewMessage([]byte(msg))), "message %d", i)
129127
}
130128

131-
// Verify the rows landed in BigQuery.
129+
// Then all 3 rows land in the BigQuery table.
130+
t.Log("Then all 3 rows are present in the BigQuery table")
132131
assert.Eventually(t, func() bool {
133132
it := bqClient.Dataset(datasetID).Table(tableID).Read(t.Context())
134133
var count int

0 commit comments

Comments
 (0)