Skip to content

Commit 197265b

Browse files
committed
fix: use kestra_unit_test bq dataset
1 parent 20da5dc commit 197265b

4 files changed

Lines changed: 57 additions & 5 deletions

File tree

.github/cleanup-unit.sh

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
set -euo pipefail
2+
3+
echo $GOOGLE_SERVICE_ACCOUNT | base64 -d > src/test/resources/.gcp-service-account.json
4+
5+
# Authenticate gcloud with the decoded service account
6+
gcloud auth activate-service-account --key-file=src/test/resources/.gcp-service-account.json
7+
8+
PROJECT_ID="kestra-unit-test"
9+
DATASET="kestra_unit_test"
10+
11+
echo "🧹 Deleting test tables from ${PROJECT_ID}:${DATASET}..."
12+
13+
# List of tables created in setup-unit.sh
14+
TABLES=(
15+
"orderDetail"
16+
"territory"
17+
)
18+
19+
for TABLE in "${TABLES[@]}"; do
20+
echo "🗑️ Deleting table ${TABLE}..."
21+
bq rm -f -t "${PROJECT_ID}:${DATASET}.${TABLE}" || echo "⚠️ Table ${TABLE} not found, skipping."
22+
done
23+
24+
echo "✅ Test tables cleaned up successfully"

.github/setup-unit.sh

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,29 @@
1-
echo $GOOGLE_SERVICE_ACCOUNT | base64 -d > src/test/resources/.gcp-service-account.json
1+
set -euo pipefail
2+
3+
echo $GOOGLE_SERVICE_ACCOUNT | base64 -d > src/test/resources/.gcp-service-account.json
4+
5+
# Authenticate gcloud with the decoded service account
6+
gcloud auth activate-service-account --key-file=src/test/resources/.gcp-service-account.json
7+
8+
PROJECT_ID="kestra-unit-test"
9+
DATASET="kestra_unit_test" # already created via terraform
10+
11+
echo "📋 Creating test tables in existing dataset ${PROJECT_ID}:${DATASET}..."
12+
13+
# orderDetail table: used in 'run' and 'error' tests
14+
bq query --use_legacy_sql=false "
15+
CREATE OR REPLACE TABLE \`${PROJECT_ID}.${DATASET}.orderDetail\` AS
16+
SELECT 1 AS id, 10.5 AS unitPrice, TIMESTAMP_SUB(CURRENT_TIMESTAMP(), INTERVAL 1 DAY) AS addedDate
17+
UNION ALL
18+
SELECT 2 AS id, 200.0 AS unitPrice, TIMESTAMP_SUB(CURRENT_TIMESTAMP(), INTERVAL 2 DAY) AS addedDate;
19+
"
20+
21+
# territory table: used in 'failed' test
22+
bq query --use_legacy_sql=false "
23+
CREATE OR REPLACE TABLE \`${PROJECT_ID}.${DATASET}.territory\` AS
24+
SELECT 1 AS id, 'North' AS name, 1 AS regionId
25+
UNION ALL
26+
SELECT 2 AS id, 'South' AS name, 4 AS regionId;
27+
"
28+
29+
echo "✅ Dataset ${PROJECT_ID}:${DATASET} ready for tests"

src/main/java/io/kestra/plugin/soda/Scan.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
type: bigquery
5151
connection:
5252
project_id: kestra-unit-test
53-
dataset: demo
53+
dataset: kestra_unit_test
5454
account_info_json: |
5555
{{ secret('GCP_CREDS') }}
5656
checks:

src/test/java/io/kestra/plugin/soda/ScanTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ void run() throws Exception {
3939
" type: bigquery\n" +
4040
" connection:\n" +
4141
" project_id: \"kestra-unit-test\"\n" +
42-
" dataset: demo\n" +
42+
" dataset: kestra_unit_test\n" +
4343
" account_info_json: |\n" +
4444
" " + StringUtils.replace(UtilsTest.serviceAccount(), "\n", "\n "),
4545
TYPE_REFERENCE
@@ -75,7 +75,7 @@ void failed() throws Exception {
7575
" type: bigquery\n" +
7676
" connection:\n" +
7777
" project_id: \"kestra-unit-test\"\n" +
78-
" dataset: demo\n" +
78+
" dataset: kestra_unit_test\n" +
7979
" account_info_json: |\n" +
8080
" " + StringUtils.replace(UtilsTest.serviceAccount(), "\n", "\n "),
8181
TYPE_REFERENCE
@@ -109,7 +109,7 @@ void error() throws Exception {
109109
" type: bigquery\n" +
110110
" connection:\n" +
111111
" project_id: \"kestra-unit-test\"\n" +
112-
" dataset: demo\n" +
112+
" dataset: kestra_unit_test\n" +
113113
" account_info_json: |\n" +
114114
" " + StringUtils.replace(UtilsTest.serviceAccount(), "\n", "\n "),
115115
TYPE_REFERENCE

0 commit comments

Comments
 (0)