Skip to content

Commit 46a5293

Browse files
authored
fix json test (#67)
* fix json test
1 parent bf7e8ee commit 46a5293

File tree

2 files changed

+27
-3
lines changed

2 files changed

+27
-3
lines changed

.github/workflows/run-tests.yaml

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,15 @@ jobs:
99
GORM_ORACLEDB_USER: ${{ secrets.GORM_ORACLEDB_USER }}
1010
GORM_ORACLEDB_PASSWORD: ${{ secrets.GORM_ORACLEDB_PASSWORD }}
1111
GORM_ORACLEDB_CONNECTSTRING: ${{ secrets.GORM_ORACLEDB_CONNECTSTRING }}
12+
GORM_SYS_PASSOWRD: ${{ secrets.GORM_SYS_PASSOWRD }}
1213
GORM_ORACLEDB_LIBDIR: /home/runner/work/_temp/instantclient_23_9
1314
services:
1415
oracle:
1516
image: gvenzl/oracle-free:latest
1617
env:
1718
APP_USER: ${{ env.GORM_ORACLEDB_USER }}
1819
APP_USER_PASSWORD: ${{ env.GORM_ORACLEDB_PASSWORD }}
19-
ORACLE_RANDOM_PASSWORD: yes
20+
ORACLE_PASSWORD: ${{ env.GORM_SYS_PASSOWRD }}
2021
ports:
2122
- 1521:1521
2223
steps:
@@ -29,15 +30,38 @@ jobs:
2930
- name: Install Oracle Instant Client
3031
run: |
3132
cd $RUNNER_TEMP
32-
# Download the desired Oracle Instant Client zip files
33+
# Download the desired Oracle Instant Client zip files and SQL*Plus packages
3334
curl -sSfLO "https://download.oracle.com/otn_software/linux/instantclient/2390000/instantclient-basic-linux.x64-23.9.0.25.07.zip"
35+
curl -sSfLO "https://download.oracle.com/otn_software/linux/instantclient/2390000/instantclient-sqlplus-linux.x64-23.9.0.25.07.zip"
3436
# Unzip the packages into a single directory
3537
unzip -q -o "instantclient-basic-linux.x64-23.9.0.25.07.zip"
38+
unzip -q -o "instantclient-sqlplus-linux.x64-23.9.0.25.07.zip"
3639
# Install the operating system libaio package
3740
sudo ln -s /usr/lib/x86_64-linux-gnu/libaio.so.1t64 /usr/lib/libaio.so.1
3841
# Update the runtime link path
3942
echo "/home/runner/work/_temp/instantclient_23_9" | sudo tee /etc/ld.so.conf.d/oracle-instantclient.conf
4043
sudo ldconfig
44+
45+
- name: Wait for Oracle to be ready
46+
run: |
47+
# Wait until Oracle is accepting connections
48+
for i in {1..30}; do
49+
if docker exec $(docker ps -qf "ancestor=gvenzl/oracle-free:latest") \
50+
bash -c "echo exit | sqlplus -s / as sysdba" >/dev/null 2>&1; then
51+
echo "Oracle is ready!"
52+
break
53+
fi
54+
echo "Waiting for Oracle..."
55+
sleep 10
56+
done
57+
58+
- name: Alter user quota on tablespace SYSAUX
59+
run: |
60+
cat <<EOF > alter_user.sql
61+
ALTER USER $GORM_ORACLEDB_USER QUOTA UNLIMITED ON SYSAUX;
62+
EOF
63+
64+
$GORM_ORACLEDB_LIBDIR/sqlplus -s "sys/${GORM_SYS_PASSOWRD}@${GORM_ORACLEDB_CONNECTSTRING} AS SYSDBA" @alter_user.sql
4165
4266
- name: Checkout
4367
uses: actions/checkout@v4

tests/json_bulk_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ func TestBasicCRUD_JSONText(t *testing.T) {
5656
}
5757

5858
DB.Migrator().DropTable(&JsonRecord{})
59-
if err := DB.AutoMigrate(&JsonRecord{}); err != nil {
59+
if err := DB.Set("gorm:table_options", "TABLESPACE SYSAUX").AutoMigrate(&JsonRecord{}); err != nil {
6060
t.Fatalf("migrate failed: %v", err)
6161
}
6262

0 commit comments

Comments
 (0)