From f740f61fbbe06da0381d899376cbf99853630b88 Mon Sep 17 00:00:00 2001 From: Eyal Posener Date: Sat, 6 May 2017 23:06:58 +0300 Subject: [test] chdir and set logger only once --- tests.go | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 tests.go (limited to 'tests.go') diff --git a/tests.go b/tests.go new file mode 100644 index 0000000..38fe5f1 --- /dev/null +++ b/tests.go @@ -0,0 +1,26 @@ +package complete + +import ( + "os" + "sync" + "testing" +) + +var once = sync.Once{} + +func initTests() { + once.Do(func() { + // Set debug environment variable so logs will be printed + if testing.Verbose() { + os.Setenv(envDebug, "1") + // refresh the logger with environment variable set + Log = getLogger() + } + + // Change to tests directory for testing completion of files and directories + err := os.Chdir("./tests") + if err != nil { + panic(err) + } + }) +} -- cgit v1.2.3