Skip to content
Snippets Groups Projects
Commit 4b767cf6 authored by Kir Kolyshkin's avatar Kir Kolyshkin Committed by Gopher Robot
Browse files

os: simplify TestRemoveAllDot

Use t.Chdir and t.TempDir to simplify test case code.

Change-Id: If4de06d2373100ce53a5b8f6702d5f4866e3b23d
Reviewed-on: https://go-review.googlesource.com/c/go/+/606897


Auto-Submit: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: default avatarIan Lance Taylor <iant@google.com>
Reviewed-by: default avatarTobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: default avatarCherry Mui <cherryyz@google.com>
parent 5164f616
No related branches found
No related tags found
No related merge requests found
...@@ -187,30 +187,11 @@ func TestRemoveAllLongPath(t *testing.T) { ...@@ -187,30 +187,11 @@ func TestRemoveAllLongPath(t *testing.T) {
} }
func TestRemoveAllDot(t *testing.T) { func TestRemoveAllDot(t *testing.T) {
prevDir, err := Getwd() t.Chdir(t.TempDir())
if err != nil {
t.Fatalf("Could not get wd: %s", err)
}
tempDir, err := MkdirTemp("", "TestRemoveAllDot-")
if err != nil {
t.Fatalf("Could not create TempDir: %s", err)
}
defer RemoveAll(tempDir)
err = Chdir(tempDir) if err := RemoveAll("."); err == nil {
if err != nil {
t.Fatalf("Could not chdir to tempdir: %s", err)
}
err = RemoveAll(".")
if err == nil {
t.Errorf("RemoveAll succeed to remove .") t.Errorf("RemoveAll succeed to remove .")
} }
err = Chdir(prevDir)
if err != nil {
t.Fatalf("Could not chdir %s: %s", prevDir, err)
}
} }
func TestRemoveAllDotDot(t *testing.T) { func TestRemoveAllDotDot(t *testing.T) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment