Merge pull request #1140 from zardak/fix-tests
Fix failing sqlite3 tests due to db connection not being closed
This commit is contained in:
		
						commit
						dda88dd08c
					
				
							
								
								
									
										17
									
								
								main_test.go
									
									
									
									
									
								
							
							
						
						
									
										17
									
								
								main_test.go
									
									
									
									
									
								
							@ -32,14 +32,6 @@ func init() {
 | 
				
			|||||||
		panic(fmt.Sprintf("No error should happen when connecting to test database, but got err=%+v", err))
 | 
							panic(fmt.Sprintf("No error should happen when connecting to test database, but got err=%+v", err))
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// DB.SetLogger(Logger{log.New(os.Stdout, "\r\n", 0)})
 | 
					 | 
				
			||||||
	// DB.SetLogger(log.New(os.Stdout, "\r\n", 0))
 | 
					 | 
				
			||||||
	if os.Getenv("DEBUG") == "true" {
 | 
					 | 
				
			||||||
		DB.LogMode(true)
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	DB.DB().SetMaxIdleConns(10)
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	runMigration()
 | 
						runMigration()
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -72,6 +64,15 @@ func OpenTestConnection() (db *gorm.DB, err error) {
 | 
				
			|||||||
		fmt.Println("testing sqlite3...")
 | 
							fmt.Println("testing sqlite3...")
 | 
				
			||||||
		db, err = gorm.Open("sqlite3", filepath.Join(os.TempDir(), "gorm.db"))
 | 
							db, err = gorm.Open("sqlite3", filepath.Join(os.TempDir(), "gorm.db"))
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						// db.SetLogger(Logger{log.New(os.Stdout, "\r\n", 0)})
 | 
				
			||||||
 | 
						// db.SetLogger(log.New(os.Stdout, "\r\n", 0))
 | 
				
			||||||
 | 
						if os.Getenv("DEBUG") == "true" {
 | 
				
			||||||
 | 
							db.LogMode(true)
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						db.DB().SetMaxIdleConns(10)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return
 | 
						return
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -628,6 +628,8 @@ func TestSelectWithVariables(t *testing.T) {
 | 
				
			|||||||
			t.Errorf("Should only contains one column")
 | 
								t.Errorf("Should only contains one column")
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						rows.Close()
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func TestSelectWithArrayInput(t *testing.T) {
 | 
					func TestSelectWithArrayInput(t *testing.T) {
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user