Skip to content

Commit 17073cb

Browse files
Remove hard coded DB connection values
1 parent 1d333bb commit 17073cb

File tree

2 files changed

+41
-6
lines changed

2 files changed

+41
-6
lines changed

tests/run-tests.sh

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,21 @@
1010
# 2. Run the script ./run_tests.sh
1111

1212
# Check for required Oracle environment variables
13-
export GORM_DSN='user="system" password="manager" \
14-
connectString="phoenix793630.dev3sub1phx.databasede3phx.oraclevcn.com:1661/cdb1_pdb1.regress.rdbms.dev.us.oracle.com" \
15-
libDir="/home/hkhasnis/projects/pkgs/23IC"'
13+
missing_vars=()
14+
for var in GORM_ORACLEDB_USER GORM_ORACLEDB_PASSWORD GORM_ORACLEDB_CONNECTSTRING GORM_ORACLEDB_LIBDIR; do
15+
if [ -z "${!var}" ]; then
16+
missing_vars+=("$var")
17+
fi
18+
done
19+
if [ ${#missing_vars[@]} -ne 0 ]; then
20+
echo "Error: The following environment variables must be set to run the tests: ${missing_vars[*]}"
21+
echo "Example:"
22+
echo " export GORM_ORACLEDB_USER=your_user"
23+
echo " export GORM_ORACLEDB_PASSWORD=your_password"
24+
echo " export GORM_ORACLEDB_CONNECTSTRING=your_connect_string"
25+
echo " export GORM_ORACLEDB_LIBDIR=your_lib_dir"
26+
exit 1
27+
fi
1628

1729
# Check if passed-tests.txt exists
1830
if [ ! -f "passed-tests.txt" ]; then

tests/tests_test.go

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,32 @@ var newLogger = logger.New(
6565
},
6666
)
6767

68-
var oracleDSN = `user="system" password="manager"
69-
connectString="phoenix793630.dev3sub1phx.databasede3phx.oraclevcn.com:1661/cdb1_pdb1.regress.rdbms.dev.us.oracle.com"
70-
libDir="/home/hkhasnis/projects/pkgs/23IC"`
68+
var oracleDSN = func() string {
69+
user := os.Getenv("GORM_ORACLEDB_USER")
70+
password := os.Getenv("GORM_ORACLEDB_PASSWORD")
71+
connectString := os.Getenv("GORM_ORACLEDB_CONNECTSTRING")
72+
libDir := os.Getenv("GORM_ORACLEDB_LIBDIR")
73+
74+
missing := []string{}
75+
if user == "" {
76+
missing = append(missing, "GORM_ORACLEDB_USER")
77+
}
78+
if password == "" {
79+
missing = append(missing, "GORM_ORACLEDB_PASSWORD")
80+
}
81+
if connectString == "" {
82+
missing = append(missing, "GORM_ORACLEDB_CONNECTSTRING")
83+
}
84+
if libDir == "" {
85+
missing = append(missing, "GORM_ORACLEDB_LIBDIR")
86+
}
87+
if len(missing) > 0 {
88+
log.Fatalf("Missing required environment variables: %v. Please set them to run the tests.", missing)
89+
}
90+
return `user="` + user + `" password="` + password + `"
91+
connectString="` + connectString + `"
92+
libDir="` + libDir + `"`
93+
}()
7194

7295
func init() {
7396
var err error

0 commit comments

Comments
 (0)