randomize db name for rest test to avoid conflicts in parallel testing

This commit is contained in:
Umputun
2019-03-06 12:15:44 -06:00
parent e638fbb2c3
commit 347fe1a0db
2 changed files with 5 additions and 1 deletions
+2
View File
@@ -6,6 +6,7 @@ import (
"fmt"
"io"
"io/ioutil"
"math/rand"
"mime/multipart"
"net/http"
"net/http/httptest"
@@ -243,6 +244,7 @@ func waitForImportCompletion(t *testing.T, ts *httptest.Server) {
}
func prepImportSrv(t *testing.T) (ts *httptest.Server, teardown func()) {
testDb := fmt.Sprintf("/tmp/test-remark-import-%d.db", rand.Int31())
b, err := engine.NewBoltDB(bolt.Options{}, engine.BoltSite{FileName: testDb, SiteID: "radio-t"})
require.Nil(t, err)
adminStore := adminstore.NewStaticStore("123456", []string{"a1", "a2"}, "admin@remark-42.com")
+3 -1
View File
@@ -4,7 +4,9 @@ import (
"bytes"
"crypto/tls"
"encoding/json"
"fmt"
"io/ioutil"
"math/rand"
"net/http"
"net/http/httptest"
"os"
@@ -29,7 +31,6 @@ import (
"github.com/umputun/remark/backend/app/store/service"
)
var testDb = "/tmp/test-remark.db"
var testHTML = "/tmp/test-remark.html"
var getStartedHTML = "/tmp/getstarted.html"
@@ -177,6 +178,7 @@ func TestRest_RunAutocertModeHTTPOnly(t *testing.T) {
func startupT(t *testing.T) (ts *httptest.Server, srv *Rest, teardown func()) {
testDb := fmt.Sprintf("/tmp/test-remark-%d.db", rand.Int31())
os.Remove(testDb)
os.Remove(testHTML)
os.RemoveAll("/tmp/ava-remark42")