1
0
mirror of https://github.com/golang/go synced 2024-11-20 05:04:43 -07:00
go/src/os/error_windows_test.go
Russ Cox c007ce824d build: move package sources from src/pkg to src
Preparation was in CL 134570043.
This CL contains only the effect of 'hg mv src/pkg/* src'.
For more about the move, see golang.org/s/go14nopkg.
2014-09-08 00:08:51 -04:00

48 lines
972 B
Go

// 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
}
}