-
Notifications
You must be signed in to change notification settings - Fork 0
/
error_windows_test.go
47 lines (41 loc) · 972 Bytes
/
error_windows_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
// Copyright 2012 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package os_test
import (
"io/ioutil"
"os"
"path/filepath"
"testing"
)
func TestErrIsExistAfterRename(t *testing.T) {
dir, err := ioutil.TempDir("", "go-build")
if err != nil {
t.Fatalf("Create temp directory: %v", err)
}
defer os.RemoveAll(dir)
src := filepath.Join(dir, "src")
dest := filepath.Join(dir, "dest")
f, err := os.Create(src)
if err != nil {
t.Fatalf("Create file %v: %v", src, err)
}
f.Close()
err = os.Rename(src, dest)
if err != nil {
t.Fatalf("Rename %v to %v: %v", src, dest, err)
}
f, err = os.Create(src)
if err != nil {
t.Fatalf("Create file %v: %v", src, err)
}
f.Close()
err = os.Rename(src, dest)
if err == nil {
t.Fatal("Rename should have failed")
}
if s := checkErrorPredicate("os.IsExist", os.IsExist, err); s != "" {
t.Fatal(s)
return
}
}