github.com/demonoid81/moby@v0.0.0-20200517203328-62dd8e17c460/daemon/logger/loggerutils/file_windows_test.go (about) 1 package loggerutils 2 3 import ( 4 "io/ioutil" 5 "os" 6 "path/filepath" 7 "testing" 8 9 "gotest.tools/v3/assert" 10 ) 11 12 func TestOpenFileDelete(t *testing.T) { 13 tmpDir, err := ioutil.TempDir("", t.Name()) 14 assert.NilError(t, err) 15 defer os.RemoveAll(tmpDir) 16 17 f, err := openFile(filepath.Join(tmpDir, "test.txt"), os.O_CREATE|os.O_RDWR, 644) 18 assert.NilError(t, err) 19 defer f.Close() 20 21 assert.NilError(t, os.RemoveAll(f.Name())) 22 } 23 24 func TestOpenFileRename(t *testing.T) { 25 tmpDir, err := ioutil.TempDir("", t.Name()) 26 assert.NilError(t, err) 27 defer os.RemoveAll(tmpDir) 28 29 f, err := openFile(filepath.Join(tmpDir, "test.txt"), os.O_CREATE|os.O_RDWR, 0644) 30 assert.NilError(t, err) 31 defer f.Close() 32 33 assert.NilError(t, os.Rename(f.Name(), f.Name()+"renamed")) 34 }