[lxc-devel] [lxd/master] testhelpers: Only build when running tests

stgraber on Github lxc-bot at linuxcontainers.org
Tue Sep 26 17:16:51 UTC 2017


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 354 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20170926/f087ad1d/attachment.bin>
-------------- next part --------------
From 0e75c0185b02228f4210f1b1ac5a6e65afe87701 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgraber at ubuntu.com>
Date: Tue, 26 Sep 2017 13:16:20 -0400
Subject: [PATCH] testhelpers: Only build when running tests
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Signed-off-by: Stéphane Graber <stgraber at ubuntu.com>
---
 shared/testhelpers/tempfile.go      | 18 ------------------
 shared/testhelpers/tempfile_test.go | 19 +++++++++++++++++++
 2 files changed, 19 insertions(+), 18 deletions(-)
 create mode 100644 shared/testhelpers/tempfile_test.go

diff --git a/shared/testhelpers/tempfile.go b/shared/testhelpers/tempfile.go
index b1abebe7e..df4bd4fb1 100644
--- a/shared/testhelpers/tempfile.go
+++ b/shared/testhelpers/tempfile.go
@@ -1,19 +1 @@
 package testhelpers
-
-import (
-	"os"
-
-	"github.com/stretchr/testify/suite"
-
-	"github.com/lxc/lxd/shared"
-)
-
-// WriteTempFile writes content to a temporary file.
-func WriteTempFile(s suite.Suite, dir string, prefix string, content string) (string, func()) {
-	filename, err := shared.WriteTempFile(dir, prefix, content)
-	if err != nil {
-		s.T().Fatalf("failed to create temporary file: %v", err)
-	}
-
-	return filename, func() { os.Remove(filename) }
-}
diff --git a/shared/testhelpers/tempfile_test.go b/shared/testhelpers/tempfile_test.go
new file mode 100644
index 000000000..b1abebe7e
--- /dev/null
+++ b/shared/testhelpers/tempfile_test.go
@@ -0,0 +1,19 @@
+package testhelpers
+
+import (
+	"os"
+
+	"github.com/stretchr/testify/suite"
+
+	"github.com/lxc/lxd/shared"
+)
+
+// WriteTempFile writes content to a temporary file.
+func WriteTempFile(s suite.Suite, dir string, prefix string, content string) (string, func()) {
+	filename, err := shared.WriteTempFile(dir, prefix, content)
+	if err != nil {
+		s.T().Fatalf("failed to create temporary file: %v", err)
+	}
+
+	return filename, func() { os.Remove(filename) }
+}


More information about the lxc-devel mailing list