(t *testing.T)
| 8 | ) |
| 9 | |
| 10 | func 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 | } |
nothing calls this directly
no test coverage detected