]> Cypherpunks repositories - gostls13.git/commitdiff
path/filepath: add a test case for EvalSymlinks error
authorHiroshi Ioka <hirochachacha@gmail.com>
Thu, 18 Aug 2016 09:40:02 +0000 (18:40 +0900)
committerBrad Fitzpatrick <bradfitz@golang.org>
Wed, 12 Oct 2016 14:01:03 +0000 (14:01 +0000)
EvalSymlinks returns error if given path or its target path don't exist.
Add a test for future improvement.

Change-Id: Ic9a4aa5eaee0fe7ac523d54d8eb3132a11b380b3
Reviewed-on: https://go-review.googlesource.com/27330
Reviewed-by: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>

src/path/filepath/path_test.go

index 737db6c93ac47eadbcc050c06e7a87832dcfe00d..e319e3c9733357864fd01f566927fe52303ae91e 100644 (file)
@@ -962,6 +962,28 @@ func TestEvalSymlinks(t *testing.T) {
        }
 }
 
+func TestEvalSymlinksIsNotExist(t *testing.T) {
+       testenv.MustHaveSymlink(t)
+
+       defer chtmpdir(t)()
+
+       _, err := filepath.EvalSymlinks("notexist")
+       if !os.IsNotExist(err) {
+               t.Errorf("expected the file is not found, got %v\n", err)
+       }
+
+       err = os.Symlink("notexist", "link")
+       if err != nil {
+               t.Fatal(err)
+       }
+       defer os.Remove("link")
+
+       _, err = filepath.EvalSymlinks("link")
+       if !os.IsNotExist(err) {
+               t.Errorf("expected the file is not found, got %v\n", err)
+       }
+}
+
 func TestIssue13582(t *testing.T) {
        testenv.MustHaveSymlink(t)