(t *testing.T)
| 33 | } |
| 34 | |
| 35 | func TestFileStreamData(t *testing.T) { |
| 36 | path := createFile(t, "my-file.txt", "hello-world") |
| 37 | stream := NewFileStream(path) |
| 38 | |
| 39 | reader, err := stream.Data() |
| 40 | data, _ := io.ReadAll(reader) |
| 41 | defer func() { |
| 42 | err := reader.Close() |
| 43 | if err != nil { |
| 44 | t.Errorf("Should not return error when closing reader, but got: %v", err) |
| 45 | } |
| 46 | }() |
| 47 | |
| 48 | if string(data) != "hello-world" { |
| 49 | t.Errorf("Did not return provided data, but got: %v", string(data)) |
| 50 | } |
| 51 | if err != nil { |
| 52 | t.Errorf("Should not return error, but got: %v", err) |
| 53 | } |
| 54 | } |
| 55 | |
| 56 | func TestFileStreamFileNotFound(t *testing.T) { |
| 57 | stream := NewFileStream("unknown-path/my-file.txt") |
nothing calls this directly
no test coverage detected