The following pull request was submitted through Github.
It can be accessed and reviewed at: https://github.com/lxc/lxd/pull/3320

This e-mail was sent by the LXC bot, direct replies will not reach the author
unless they happen to be subscribed to this list.

=== Description (from pull-request) ===
Currently unit tests based on lxdSuiteTest all share the same
database, meaning that state left by certain tests can influence other
tests (for instance it's not possible to create a pool with the same
name in two different tests).

This change resets the db state after each individual test run,
increasing isolation between tests.

Signed-off-by: Free Ekanayaka <[email protected]>
From 7c5c5ba9dca8297f7b213ce9a7a462084be98aef Mon Sep 17 00:00:00 2001
From: Free Ekanayaka <[email protected]>
Date: Tue, 16 May 2017 09:55:41 +0200
Subject: [PATCH] Clear database state in the mock daemon after each
 lxdSuiteTest

Currently unit tests based on lxdSuiteTest all share the same
database, meaning that state left by certain tests can influence other
tests (for instance it's not possible to create a pool with the same
name in two different tests).

This change resets the db state after each individual test run,
increasing isolation between tests.

Signed-off-by: Free Ekanayaka <[email protected]>
---
 lxd/main_test.go | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/lxd/main_test.go b/lxd/main_test.go
index 9a1530a..382ce27 100644
--- a/lxd/main_test.go
+++ b/lxd/main_test.go
@@ -106,5 +106,15 @@ func (suite *lxdTestSuite) TearDownSuite() {
 }
 
 func (suite *lxdTestSuite) SetupTest() {
+       initializeDbObject(suite.d, shared.VarPath("lxd.db"))
+       daemonConfigInit(suite.d.db)
        suite.Req = require.New(suite.T())
 }
+
+func (suite *lxdTestSuite) TearDownTest() {
+       suite.d.db.Close()
+       err := os.Remove(shared.VarPath("lxd.db"))
+       if err != nil {
+               os.Exit(1)
+       }
+}
_______________________________________________
lxc-devel mailing list
[email protected]
http://lists.linuxcontainers.org/listinfo/lxc-devel

Reply via email to