@@ -32,12 +32,10 @@ func setupDBTest(t *testing.T) string {
3232
3333 // Reset global config and viper to ensure test isolation
3434 config .ResetGlobalConfig ()
35- viper .Reset ()
3635
3736 t .Cleanup (func () {
3837 // Reset global config and viper first
3938 config .ResetGlobalConfig ()
40- viper .Reset ()
4139 // Clean up environment variable BEFORE cleaning up file system
4240 os .Unsetenv ("TIGER_CONFIG_DIR" )
4341 // Then clean up file system
@@ -64,12 +62,10 @@ func TestDBConnectionString_NoServiceID(t *testing.T) {
6462 tmpDir := setupDBTest (t )
6563
6664 // Set up config with project ID but no default service ID
67- cfg := & config.Config {
68- APIURL : "https://api.tigerdata.com/public/v1" ,
69- ProjectID : "test-project-123" ,
70- ConfigDir : tmpDir ,
71- }
72- err := cfg .Save ()
65+ _ , err := config .UseTestConfig (tmpDir , map [string ]any {
66+ "api_url" : "https://api.tigerdata.com/public/v1" ,
67+ "project_id" : "test-project-123" ,
68+ })
7369 if err != nil {
7470 t .Fatalf ("Failed to save test config: %v" , err )
7571 }
@@ -96,13 +92,11 @@ func TestDBConnectionString_NoAuth(t *testing.T) {
9692 tmpDir := setupDBTest (t )
9793
9894 // Set up config with project ID and service ID
99- cfg := & config.Config {
100- APIURL : "https://api.tigerdata.com/public/v1" ,
101- ProjectID : "test-project-123" ,
102- ServiceID : "svc-12345" ,
103- ConfigDir : tmpDir ,
104- }
105- err := cfg .Save ()
95+ _ , err := config .UseTestConfig (tmpDir , map [string ]any {
96+ "api_url" : "https://api.tigerdata.com/public/v1" ,
97+ "project_id" : "test-project-123" ,
98+ "service_id" : "svc-12345" ,
99+ })
106100 if err != nil {
107101 t .Fatalf ("Failed to save test config: %v" , err )
108102 }
@@ -172,12 +166,10 @@ func TestDBConnect_NoServiceID(t *testing.T) {
172166 tmpDir := setupDBTest (t )
173167
174168 // Set up config with project ID but no default service ID
175- cfg := & config.Config {
176- APIURL : "https://api.tigerdata.com/public/v1" ,
177- ProjectID : "test-project-123" ,
178- ConfigDir : tmpDir ,
179- }
180- err := cfg .Save ()
169+ _ , err := config .UseTestConfig (tmpDir , map [string ]any {
170+ "api_url" : "https://api.tigerdata.com/public/v1" ,
171+ "project_id" : "test-project-123" ,
172+ })
181173 if err != nil {
182174 t .Fatalf ("Failed to save test config: %v" , err )
183175 }
@@ -204,13 +196,11 @@ func TestDBConnect_NoAuth(t *testing.T) {
204196 tmpDir := setupDBTest (t )
205197
206198 // Set up config with project ID and service ID
207- cfg := & config.Config {
208- APIURL : "https://api.tigerdata.com/public/v1" ,
209- ProjectID : "test-project-123" ,
210- ServiceID : "svc-12345" ,
211- ConfigDir : tmpDir ,
212- }
213- err := cfg .Save ()
199+ _ , err := config .UseTestConfig (tmpDir , map [string ]any {
200+ "api_url" : "https://api.tigerdata.com/public/v1" ,
201+ "project_id" : "test-project-123" ,
202+ "service_id" : "svc-12345" ,
203+ })
214204 if err != nil {
215205 t .Fatalf ("Failed to save test config: %v" , err )
216206 }
@@ -237,13 +227,11 @@ func TestDBConnect_PsqlNotFound(t *testing.T) {
237227 tmpDir := setupDBTest (t )
238228
239229 // Set up config
240- cfg := & config.Config {
241- APIURL : "http://localhost:9999" ,
242- ProjectID : "test-project-123" ,
243- ServiceID : "svc-12345" ,
244- ConfigDir : tmpDir ,
245- }
246- err := cfg .Save ()
230+ _ , err := config .UseTestConfig (tmpDir , map [string ]any {
231+ "api_url" : "http://localhost:9999" ,
232+ "project_id" : "test-project-123" ,
233+ "service_id" : "svc-12345" ,
234+ })
247235 if err != nil {
248236 t .Fatalf ("Failed to save test config: %v" , err )
249237 }
@@ -596,12 +584,10 @@ func TestDBTestConnection_NoServiceID(t *testing.T) {
596584 tmpDir := setupDBTest (t )
597585
598586 // Set up config with project ID but no default service ID
599- cfg := & config.Config {
600- APIURL : "https://api.tigerdata.com/public/v1" ,
601- ProjectID : "test-project-123" ,
602- ConfigDir : tmpDir ,
603- }
604- err := cfg .Save ()
587+ _ , err := config .UseTestConfig (tmpDir , map [string ]any {
588+ "api_url" : "https://api.tigerdata.com/public/v1" ,
589+ "project_id" : "test-project-123" ,
590+ })
605591 if err != nil {
606592 t .Fatalf ("Failed to save test config: %v" , err )
607593 }
@@ -628,13 +614,11 @@ func TestDBTestConnection_NoAuth(t *testing.T) {
628614 tmpDir := setupDBTest (t )
629615
630616 // Set up config with project ID and service ID
631- cfg := & config.Config {
632- APIURL : "https://api.tigerdata.com/public/v1" ,
633- ProjectID : "test-project-123" ,
634- ServiceID : "svc-12345" ,
635- ConfigDir : tmpDir ,
636- }
637- err := cfg .Save ()
617+ _ , err := config .UseTestConfig (tmpDir , map [string ]any {
618+ "api_url" : "https://api.tigerdata.com/public/v1" ,
619+ "project_id" : "test-project-123" ,
620+ "service_id" : "svc-12345" ,
621+ })
638622 if err != nil {
639623 t .Fatalf ("Failed to save test config: %v" , err )
640624 }
@@ -980,13 +964,11 @@ func TestDBTestConnection_TimeoutParsing(t *testing.T) {
980964 tmpDir := setupDBTest (t )
981965
982966 // Set up config
983- cfg := & config.Config {
984- APIURL : "http://localhost:9999" , // Non-existent server
985- ProjectID : "test-project-123" ,
986- ServiceID : "svc-12345" ,
987- ConfigDir : tmpDir ,
988- }
989- err := cfg .Save ()
967+ _ , err := config .UseTestConfig (tmpDir , map [string ]any {
968+ "api_url" : "http://localhost:9999" , // Non-existent server
969+ "project_id" : "test-project-123" ,
970+ "service_id" : "svc-12345" ,
971+ })
990972 if err != nil {
991973 t .Fatalf ("Failed to save test config: %v" , err )
992974 }
0 commit comments