(t *testing.T)
| 16 | } |
| 17 | |
| 18 | func TestCreateOutputFile(t *testing.T) { |
| 19 | |
| 20 | fileName := "test_output.txt" |
| 21 | message := "test message" |
| 22 | err := CreateOutputFile(message, fileName) |
| 23 | if err != nil { |
| 24 | t.Fatalf("CreateOutputFile() error = %v", err) |
| 25 | } |
| 26 | |
| 27 | t.Cleanup(func() { os.Remove(fileName) }) |
| 28 | |
| 29 | data, err := os.ReadFile(fileName) |
| 30 | if err != nil { |
| 31 | t.Fatalf("failed to read output file: %v", err) |
| 32 | } |
| 33 | |
| 34 | expected := message + "\n" |
| 35 | if string(data) != expected { |
| 36 | t.Fatalf("expected file contents %q, got %q", expected, data) |
| 37 | } |
| 38 | } |
| 39 | |
| 40 | func TestCreateOutputFileMessageWithTrailingNewline(t *testing.T) { |
| 41 | fileName := "test_output_with_newline.txt" |
nothing calls this directly
no test coverage detected