From 3a138a9b5e50fcacc05279ad7323a5ccf30a81ea Mon Sep 17 00:00:00 2001 From: Yohei Ueda Date: Fri, 7 Nov 2014 02:17:02 +0900 Subject: [PATCH] Fix the unit test not to remove /tmp Signed-off-by: Yohei Ueda --- parsers/operatingsystem/operatingsystem_test.go | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/parsers/operatingsystem/operatingsystem_test.go b/parsers/operatingsystem/operatingsystem_test.go index d264b35..b7d54cb 100644 --- a/parsers/operatingsystem/operatingsystem_test.go +++ b/parsers/operatingsystem/operatingsystem_test.go @@ -38,12 +38,13 @@ BUG_REPORT_URL="http://bugs.launchpad.net/ubuntu/"`) ) dir := os.TempDir() + etcOsRelease = filepath.Join(dir, "etcOsRelease") + defer func() { + os.Remove(etcOsRelease) etcOsRelease = backup - os.RemoveAll(dir) }() - etcOsRelease = filepath.Join(dir, "etcOsRelease") for expect, osRelease := range map[string][]byte{ "Ubuntu 14.04 LTS": ubuntuTrusty, "Gentoo/Linux": gentoo, @@ -92,13 +93,13 @@ func TestIsContainerized(t *testing.T) { ) dir := os.TempDir() - defer func() { - proc1Cgroup = backup - os.RemoveAll(dir) - }() - proc1Cgroup = filepath.Join(dir, "proc1Cgroup") + defer func() { + os.Remove(proc1Cgroup) + proc1Cgroup = backup + }() + if err := ioutil.WriteFile(proc1Cgroup, nonContainerizedProc1Cgroup, 0600); err != nil { t.Fatalf("failed to write to %s: %v", proc1Cgroup, err) }