1
0
mirror of https://github.com/mattermost/focalboard.git synced 2025-02-01 19:14:35 +02:00

Sqlite in-memory database for unit tests (#2599)

* unit tests use in-memory DB for sqlite
This commit is contained in:
Doug Lauder 2022-03-23 14:14:07 -04:00 committed by GitHub
parent 22a92068b5
commit 218d901b0d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 4 additions and 11 deletions

View File

@ -2,10 +2,9 @@
"serverRoot": "http://localhost:8000",
"port": 8000,
"dbtype": "sqlite3",
"dbconfig": "./focalboard.db",
"dbconfig": "./focalboard.db?_busy_timeout=5000",
"dbtableprefix": "",
"postgres_dbconfig": "dbname=focalboard sslmode=disable",
"test_dbconfig": "file::memory:?cache=shared",
"useSSL": false,
"webpath": "./webapp/pack",
"filesdriver": "local",

View File

@ -3,7 +3,6 @@ package sqlstore
import (
"database/sql"
"fmt"
"io/ioutil"
"os"
"strings"
@ -34,12 +33,7 @@ func PrepareNewTestDatabase() (dbType string, connectionString string, err error
var rootUser string
if dbType == model.SqliteDBType {
file, err := ioutil.TempFile("", "fbtest_*.db")
if err != nil {
return "", "", err
}
connectionString = file.Name()
_ = file.Close()
connectionString = "file::memory:?cache=shared&_busy_timeout=5000"
} else if port := strings.TrimSpace(os.Getenv("FB_STORE_TEST_DOCKER_PORT")); port != "" {
// docker unit tests take priority over any DSN env vars
var template string

View File

@ -2,7 +2,7 @@
"serverRoot": "http://localhost:8088",
"port": 8088,
"dbtype": "sqlite3",
"dbconfig": "file::memory:?cache=shared",
"dbconfig": "file::memory:?cache=shared&_busy_timeout=5000",
"useSSL": false,
"webpath": "../pack",
"filespath": "../../files",

View File

@ -76,7 +76,7 @@ Cypress.Commands.add('apiResetBoards', () => {
}).then((response) => {
if (Array.isArray(response.body)) {
const boards = response.body as Board[]
const toDelete = boards.filter((b) => !b.fields.isTemplate).map((b) => b.id)
const toDelete = boards.filter((b) => !b.isTemplate).map((b) => b.id)
deleteBlocks(toDelete)
}
})