[lxc-devel] [lxd/master] Use in-memory db for tests (makes them faster)

albertodonato on Github lxc-bot at linuxcontainers.org
Wed May 31 13:37:02 UTC 2017


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 361 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20170531/e7b4576c/attachment.bin>
-------------- next part --------------
From 63d6122d96ae80da97e9808d358dea3d414324af Mon Sep 17 00:00:00 2001
From: Alberto Donato <alberto.donato at canonical.com>
Date: Wed, 31 May 2017 15:35:32 +0200
Subject: [PATCH] Use in-memory db for tests (makes them faster)

Signed-off-by: Alberto Donato <alberto.donato at canonical.com>
---
 lxd/main_test.go | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/lxd/main_test.go b/lxd/main_test.go
index 6f8969371..4db9162a2 100644
--- a/lxd/main_test.go
+++ b/lxd/main_test.go
@@ -77,7 +77,7 @@ func (suite *lxdTestSuite) TearDownSuite() {
 }
 
 func (suite *lxdTestSuite) SetupTest() {
-	initializeDbObject(suite.d, shared.VarPath("lxd.db"))
+	initializeDbObject(suite.d, ":memory:")
 	daemonConfigInit(suite.d.db)
 
 	// Create default storage pool. Make sure that we don't pass a nil to
@@ -124,8 +124,4 @@ func (suite *lxdTestSuite) SetupTest() {
 
 func (suite *lxdTestSuite) TearDownTest() {
 	suite.d.db.Close()
-	err := os.Remove(shared.VarPath("lxd.db"))
-	if err != nil {
-		os.Exit(1)
-	}
 }


More information about the lxc-devel mailing list