Skip to content

Commit

Permalink
os: use t.TempDir in TestReadOnlyWriteFile
Browse files Browse the repository at this point in the history
This test is checking WriteFile, not MkdirTemp, and using t.TempDir
makes the test case code a tad smaller and simpler.

Change-Id: I48837f77572f375d56f3a387efa9a4ee1d3706fd
Reviewed-on: https://go-review.googlesource.com/c/go/+/606898
Reviewed-by: Cherry Mui <[email protected]>
Auto-Submit: Ian Lance Taylor <[email protected]>
Reviewed-by: Ian Lance Taylor <[email protected]>
LUCI-TryBot-Result: Go LUCI <[email protected]>
  • Loading branch information
kolyshkin authored and gopherbot committed Aug 20, 2024
1 parent 4b767cf commit ef0b015
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions src/os/read_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,16 +78,11 @@ func TestReadOnlyWriteFile(t *testing.T) {
t.Parallel()

// We don't want to use CreateTemp directly, since that opens a file for us as 0600.
tempDir, err := MkdirTemp("", t.Name())
if err != nil {
t.Fatal(err)
}
defer RemoveAll(tempDir)
filename := filepath.Join(tempDir, "blurp.txt")
filename := filepath.Join(t.TempDir(), "blurp.txt")

shmorp := []byte("shmorp")
florp := []byte("florp")
err = WriteFile(filename, shmorp, 0444)
err := WriteFile(filename, shmorp, 0444)
if err != nil {
t.Fatalf("WriteFile %s: %v", filename, err)
}
Expand Down

0 comments on commit ef0b015

Please sign in to comment.