MCPcopy Create free account
hub / github.com/danielmiessler/Fabric / TestCreateOutputFile

Function TestCreateOutputFile

internal/cli/output_test.go:18–38  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

16}
17
18func 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
40func TestCreateOutputFileMessageWithTrailingNewline(t *testing.T) {
41 fileName := "test_output_with_newline.txt"

Callers

nothing calls this directly

Calls 2

CreateOutputFileFunction · 0.85
RemoveMethod · 0.80

Tested by

no test coverage detected