Test: Remove temporary directory afterwards

This commit is contained in:
zonescape 2024-11-21 11:16:23 +03:00
parent 6ba0dbafd7
commit 626c70a105
2 changed files with 14 additions and 0 deletions

View file

@ -96,6 +96,7 @@ func InitializeServerConfig(config *core.Config) (*exec.Cmd, error) {
var ( var (
testBinaryPath string testBinaryPath string
testBinaryCleanFn func()
testBinaryPathGen sync.Once testBinaryPathGen sync.Once
) )
@ -108,6 +109,7 @@ func genTestBinaryPath() {
return err return err
} }
tempDir = dir tempDir = dir
testBinaryCleanFn = func() { os.RemoveAll(dir) }
return nil return nil
})) }))
file := filepath.Join(tempDir, "xray.test") file := filepath.Join(tempDir, "xray.test")

View file

@ -0,0 +1,12 @@
package scenarios
import (
"testing"
)
func TestMain(m *testing.M) {
genTestBinaryPath()
defer testBinaryCleanFn()
m.Run()
}