浏览代码

test(net): don't cause a race condition

Mustafa Arici 8 年之前
父节点
当前提交
02ad20ba17
共有 2 个文件被更改,包括 4 次插入10 次删除
  1. 4 9
      user_test.go
  2. 0 1
      vpn_test.go

+ 4 - 9
user_test.go

@@ -11,7 +11,6 @@ import (
 
 func TestCreateNewUser(t *testing.T) {
 	// Initialize:
-	ovpm.Testing = true
 	ovpm.SetupDB("sqlite3", ":memory:")
 	defer ovpm.CeaseDB()
 	ovpm.Init("localhost", "")
@@ -80,7 +79,6 @@ func TestCreateNewUser(t *testing.T) {
 
 func TestUserUpdate(t *testing.T) {
 	// Initialize:
-	ovpm.Testing = true
 	ovpm.SetupDB("sqlite3", ":memory:")
 	defer ovpm.CeaseDB()
 	ovpm.Init("localhost", "")
@@ -117,7 +115,6 @@ func TestUserUpdate(t *testing.T) {
 
 func TestUserPasswordCorrect(t *testing.T) {
 	// Initialize:
-	ovpm.Testing = true
 	ovpm.SetupDB("sqlite3", ":memory:")
 	defer ovpm.CeaseDB()
 	ovpm.Init("localhost", "")
@@ -135,7 +132,6 @@ func TestUserPasswordCorrect(t *testing.T) {
 
 func TestUserPasswordReset(t *testing.T) {
 	// Initialize:
-	ovpm.Testing = true
 	ovpm.SetupDB("sqlite3", ":memory:")
 	defer ovpm.CeaseDB()
 	ovpm.Init("localhost", "")
@@ -163,7 +159,6 @@ func TestUserPasswordReset(t *testing.T) {
 
 func TestUserDelete(t *testing.T) {
 	// Initialize:
-	ovpm.Testing = true
 	ovpm.SetupDB("sqlite3", ":memory:")
 	defer ovpm.CeaseDB()
 	ovpm.Init("localhost", "")
@@ -202,7 +197,6 @@ func TestUserDelete(t *testing.T) {
 
 func TestUserGet(t *testing.T) {
 	// Initialize:
-	ovpm.Testing = true
 	ovpm.SetupDB("sqlite3", ":memory:")
 	defer ovpm.CeaseDB()
 	ovpm.Init("localhost", "")
@@ -227,7 +221,6 @@ func TestUserGet(t *testing.T) {
 
 func TestUserGetAll(t *testing.T) {
 	// Initialize:
-	ovpm.Testing = true
 	ovpm.SetupDB("sqlite3", ":memory:")
 	defer ovpm.CeaseDB()
 	ovpm.Init("localhost", "")
@@ -266,7 +259,6 @@ func TestUserGetAll(t *testing.T) {
 
 func TestUserRenew(t *testing.T) {
 	// Initialize:
-	ovpm.Testing = true
 	ovpm.SetupDB("sqlite3", ":memory:")
 	defer ovpm.CeaseDB()
 	ovpm.Init("localhost", "")
@@ -289,7 +281,6 @@ func TestUserRenew(t *testing.T) {
 
 func TestUserIPAllocator(t *testing.T) {
 	// Initialize:
-	ovpm.Testing = true
 	ovpm.SetupDB("sqlite3", ":memory:")
 	defer ovpm.CeaseDB()
 	ovpm.Init("localhost", "")
@@ -347,3 +338,7 @@ func areUsersEqual(user1, user2 *ovpm.DBUser) bool {
 	return true
 
 }
+
+func init() {
+	ovpm.Testing = true
+}

+ 0 - 1
vpn_test.go

@@ -340,7 +340,6 @@ func TestVPNStopVPNProc(t *testing.T) {
 
 func TestVPNRestartVPNProc(t *testing.T) {
 	// Init:
-	Testing = true
 	SetupDB("sqlite3", ":memory:")
 	defer CeaseDB()
 	Init("localhost", "")