Fix the unit test not to remove /tmp
Signed-off-by: Yohei Ueda <yohei@jp.ibm.com>
This commit is contained in:
parent
bf0a0e9ca7
commit
3a138a9b5e
1 changed files with 8 additions and 7 deletions
|
@ -38,12 +38,13 @@ BUG_REPORT_URL="http://bugs.launchpad.net/ubuntu/"`)
|
||||||
)
|
)
|
||||||
|
|
||||||
dir := os.TempDir()
|
dir := os.TempDir()
|
||||||
|
etcOsRelease = filepath.Join(dir, "etcOsRelease")
|
||||||
|
|
||||||
defer func() {
|
defer func() {
|
||||||
|
os.Remove(etcOsRelease)
|
||||||
etcOsRelease = backup
|
etcOsRelease = backup
|
||||||
os.RemoveAll(dir)
|
|
||||||
}()
|
}()
|
||||||
|
|
||||||
etcOsRelease = filepath.Join(dir, "etcOsRelease")
|
|
||||||
for expect, osRelease := range map[string][]byte{
|
for expect, osRelease := range map[string][]byte{
|
||||||
"Ubuntu 14.04 LTS": ubuntuTrusty,
|
"Ubuntu 14.04 LTS": ubuntuTrusty,
|
||||||
"Gentoo/Linux": gentoo,
|
"Gentoo/Linux": gentoo,
|
||||||
|
@ -92,13 +93,13 @@ func TestIsContainerized(t *testing.T) {
|
||||||
)
|
)
|
||||||
|
|
||||||
dir := os.TempDir()
|
dir := os.TempDir()
|
||||||
defer func() {
|
|
||||||
proc1Cgroup = backup
|
|
||||||
os.RemoveAll(dir)
|
|
||||||
}()
|
|
||||||
|
|
||||||
proc1Cgroup = filepath.Join(dir, "proc1Cgroup")
|
proc1Cgroup = filepath.Join(dir, "proc1Cgroup")
|
||||||
|
|
||||||
|
defer func() {
|
||||||
|
os.Remove(proc1Cgroup)
|
||||||
|
proc1Cgroup = backup
|
||||||
|
}()
|
||||||
|
|
||||||
if err := ioutil.WriteFile(proc1Cgroup, nonContainerizedProc1Cgroup, 0600); err != nil {
|
if err := ioutil.WriteFile(proc1Cgroup, nonContainerizedProc1Cgroup, 0600); err != nil {
|
||||||
t.Fatalf("failed to write to %s: %v", proc1Cgroup, err)
|
t.Fatalf("failed to write to %s: %v", proc1Cgroup, err)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue