MCPcopy
hub / github.com/tinyauthapp/tinyauth / TestReadFile

Function TestReadFile

internal/utils/fs_utils_test.go:10–31  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

8)
9
10func TestReadFile(t *testing.T) {
11 // Setup
12 file, err := os.Create("/tmp/tinyauth_test_file")
13 assert.NilError(t, err)
14
15 _, err = file.WriteString("file content\n")
16 assert.NilError(t, err)
17
18 err = file.Close()
19 assert.NilError(t, err)
20 defer os.Remove("/tmp/tinyauth_test_file")
21
22 // Normal case
23 content, err := ReadFile("/tmp/tinyauth_test_file")
24 assert.NilError(t, err)
25 assert.Equal(t, "file content\n", content)
26
27 // Non-existing file
28 content, err = ReadFile("/tmp/non_existing_file")
29 assert.ErrorContains(t, err, "no such file or directory")
30 assert.Equal(t, "", content)
31}

Callers

nothing calls this directly

Calls 1

ReadFileFunction · 0.85

Tested by

no test coverage detected