Revert in-memory unit tests for sqlite (#2630)

* revert in-memory unit tests for sqlite

* fix unit test

* fix comments

* fix unit tests
This commit is contained in:
Doug Lauder 2022-03-24 17:45:10 -04:00 committed by GitHub
parent 70ab1afecd
commit 71cb654d71
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 2 deletions

View file

@ -27,7 +27,9 @@ func New(store permissions.Store, logger *mlog.Logger) *Service {
}
func (s *Service) HasPermissionToTeam(userID, teamID string, permission *mmModel.Permission) bool {
// Locally there is no team, so return true
if userID == "" || teamID == "" || permission == nil {
return false
}
return true
}

View file

@ -3,6 +3,7 @@ package sqlstore
import (
"database/sql"
"fmt"
"io/ioutil"
"os"
"strings"
@ -33,7 +34,12 @@ func PrepareNewTestDatabase() (dbType string, connectionString string, err error
var rootUser string
if dbType == model.SqliteDBType {
connectionString = "file::memory:?cache=shared&_busy_timeout=5000"
file, err := ioutil.TempFile("", "fbtest_*.db")
if err != nil {
return "", "", err
}
connectionString = file.Name() + "?_busy_timeout=5000"
_ = file.Close()
} 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