Skip to content

Commit

Permalink
Fix the unit test not to remove /tmp
Browse files Browse the repository at this point in the history
Signed-off-by: Yohei Ueda <[email protected]>
  • Loading branch information
yoheiueda committed Nov 6, 2014
1 parent 6fcc914 commit 2329354
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions pkg/parsers/operatingsystem/operatingsystem_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -92,13 +93,13 @@ func TestIsContainerized(t *testing.T) {
)

dir := os.TempDir()
proc1Cgroup = filepath.Join(dir, "proc1Cgroup")

defer func() {
os.Remove(proc1Cgroup)
proc1Cgroup = backup
os.RemoveAll(dir)
}()

proc1Cgroup = filepath.Join(dir, "proc1Cgroup")

if err := ioutil.WriteFile(proc1Cgroup, nonContainerizedProc1Cgroup, 0600); err != nil {
t.Fatalf("failed to write to %s: %v", proc1Cgroup, err)
}
Expand Down

0 comments on commit 2329354

Please sign in to comment.