1
0
Fork 0
mirror of https://github.com/postmannen/ctrl.git synced 2024-12-14 12:37:31 +00:00

added flag for persisting tmp with tests

This commit is contained in:
postmannen 2022-05-23 18:33:31 +02:00
parent d05667ace1
commit 0584035f6c

View file

@ -21,6 +21,7 @@ import (
) )
var logging = flag.Bool("logging", false, "set to true to enable the normal logger of the package") var logging = flag.Bool("logging", false, "set to true to enable the normal logger of the package")
var persistTmp = flag.Bool("persistTmp", false, "set to true to persist the tmp folder")
func newServerForTesting(t *testing.T, addressAndPort string, testFolder string) (*server, *Configuration) { func newServerForTesting(t *testing.T, addressAndPort string, testFolder string) (*server, *Configuration) {
if !*logging { if !*logging {
@ -120,8 +121,13 @@ func TestRequest(t *testing.T) {
} }
defer ns.Shutdown() defer ns.Shutdown()
// tempdir := t.TempDir() var tempDir string
tempDir := "tmp" if *persistTmp {
tempDir = "tmp"
} else {
tempDir = t.TempDir()
}
srv, conf := newServerForTesting(t, "127.0.0.1:42222", tempDir) srv, conf := newServerForTesting(t, "127.0.0.1:42222", tempDir)
srv.Start() srv.Start()
defer srv.Stop() defer srv.Stop()