mirror of
https://github.com/mattermost/focalboard.git
synced 2025-04-17 11:36:22 +02:00
Sqlite in-memory database for unit tests (#2599)
* unit tests use in-memory DB for sqlite
This commit is contained in:
parent
22a92068b5
commit
218d901b0d
@ -2,10 +2,9 @@
|
|||||||
"serverRoot": "http://localhost:8000",
|
"serverRoot": "http://localhost:8000",
|
||||||
"port": 8000,
|
"port": 8000,
|
||||||
"dbtype": "sqlite3",
|
"dbtype": "sqlite3",
|
||||||
"dbconfig": "./focalboard.db",
|
"dbconfig": "./focalboard.db?_busy_timeout=5000",
|
||||||
"dbtableprefix": "",
|
"dbtableprefix": "",
|
||||||
"postgres_dbconfig": "dbname=focalboard sslmode=disable",
|
"postgres_dbconfig": "dbname=focalboard sslmode=disable",
|
||||||
"test_dbconfig": "file::memory:?cache=shared",
|
|
||||||
"useSSL": false,
|
"useSSL": false,
|
||||||
"webpath": "./webapp/pack",
|
"webpath": "./webapp/pack",
|
||||||
"filesdriver": "local",
|
"filesdriver": "local",
|
||||||
|
@ -3,7 +3,6 @@ package sqlstore
|
|||||||
import (
|
import (
|
||||||
"database/sql"
|
"database/sql"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
@ -34,12 +33,7 @@ func PrepareNewTestDatabase() (dbType string, connectionString string, err error
|
|||||||
var rootUser string
|
var rootUser string
|
||||||
|
|
||||||
if dbType == model.SqliteDBType {
|
if dbType == model.SqliteDBType {
|
||||||
file, err := ioutil.TempFile("", "fbtest_*.db")
|
connectionString = "file::memory:?cache=shared&_busy_timeout=5000"
|
||||||
if err != nil {
|
|
||||||
return "", "", err
|
|
||||||
}
|
|
||||||
connectionString = file.Name()
|
|
||||||
_ = file.Close()
|
|
||||||
} else if port := strings.TrimSpace(os.Getenv("FB_STORE_TEST_DOCKER_PORT")); port != "" {
|
} else if port := strings.TrimSpace(os.Getenv("FB_STORE_TEST_DOCKER_PORT")); port != "" {
|
||||||
// docker unit tests take priority over any DSN env vars
|
// docker unit tests take priority over any DSN env vars
|
||||||
var template string
|
var template string
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
"serverRoot": "http://localhost:8088",
|
"serverRoot": "http://localhost:8088",
|
||||||
"port": 8088,
|
"port": 8088,
|
||||||
"dbtype": "sqlite3",
|
"dbtype": "sqlite3",
|
||||||
"dbconfig": "file::memory:?cache=shared",
|
"dbconfig": "file::memory:?cache=shared&_busy_timeout=5000",
|
||||||
"useSSL": false,
|
"useSSL": false,
|
||||||
"webpath": "../pack",
|
"webpath": "../pack",
|
||||||
"filespath": "../../files",
|
"filespath": "../../files",
|
||||||
|
@ -76,7 +76,7 @@ Cypress.Commands.add('apiResetBoards', () => {
|
|||||||
}).then((response) => {
|
}).then((response) => {
|
||||||
if (Array.isArray(response.body)) {
|
if (Array.isArray(response.body)) {
|
||||||
const boards = response.body as Board[]
|
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)
|
deleteBlocks(toDelete)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
Loading…
x
Reference in New Issue
Block a user