mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
9f0b3f5609
full diff: https://github.com/gotestyourself/gotest.tools/compare/v2.3.0...v3.0.1 Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
34 lines
748 B
Go
34 lines
748 B
Go
package loggerutils
|
|
|
|
import (
|
|
"io/ioutil"
|
|
"os"
|
|
"path/filepath"
|
|
"testing"
|
|
|
|
"gotest.tools/v3/assert"
|
|
)
|
|
|
|
func TestOpenFileDelete(t *testing.T) {
|
|
tmpDir, err := ioutil.TempDir("", t.Name())
|
|
assert.NilError(t, err)
|
|
defer os.RemoveAll(tmpDir)
|
|
|
|
f, err := openFile(filepath.Join(tmpDir, "test.txt"), os.O_CREATE|os.O_RDWR, 644)
|
|
assert.NilError(t, err)
|
|
defer f.Close()
|
|
|
|
assert.NilError(t, os.RemoveAll(f.Name()))
|
|
}
|
|
|
|
func TestOpenFileRename(t *testing.T) {
|
|
tmpDir, err := ioutil.TempDir("", t.Name())
|
|
assert.NilError(t, err)
|
|
defer os.RemoveAll(tmpDir)
|
|
|
|
f, err := openFile(filepath.Join(tmpDir, "test.txt"), os.O_CREATE|os.O_RDWR, 0644)
|
|
assert.NilError(t, err)
|
|
defer f.Close()
|
|
|
|
assert.NilError(t, os.Rename(f.Name(), f.Name()+"renamed"))
|
|
}
|