(t *testing.T)
| 49 | } |
| 50 | |
| 51 | func TestOpen(t *testing.T) { |
| 52 | tempName := filepath.Join(t.TempDir(), "test.log") |
| 53 | assert.False(t, fileExists(tempName)) |
| 54 | require.True(t, filepath.IsAbs(tempName), "Expected absolute temp file path.") |
| 55 | |
| 56 | tests := []struct { |
| 57 | msg string |
| 58 | paths []string |
| 59 | }{ |
| 60 | { |
| 61 | msg: "stdout", |
| 62 | paths: []string{"stdout"}, |
| 63 | }, |
| 64 | { |
| 65 | msg: "stderr", |
| 66 | paths: []string{"stderr"}, |
| 67 | }, |
| 68 | { |
| 69 | msg: "temp file path only", |
| 70 | paths: []string{tempName}, |
| 71 | }, |
| 72 | { |
| 73 | msg: "temp file file scheme", |
| 74 | paths: []string{"file://" + tempName}, |
| 75 | }, |
| 76 | { |
| 77 | msg: "temp file with file scheme and host localhost", |
| 78 | paths: []string{"file://localhost" + tempName}, |
| 79 | }, |
| 80 | } |
| 81 | |
| 82 | for _, tt := range tests { |
| 83 | t.Run(tt.msg, func(t *testing.T) { |
| 84 | _, cleanup, err := Open(tt.paths...) |
| 85 | if err == nil { |
| 86 | defer cleanup() |
| 87 | } |
| 88 | |
| 89 | assert.NoError(t, err, "Unexpected error opening paths %v.", tt.paths) |
| 90 | }) |
| 91 | } |
| 92 | |
| 93 | assert.True(t, fileExists(tempName)) |
| 94 | } |
| 95 | |
| 96 | func TestOpenPathsNotFound(t *testing.T) { |
| 97 | tempName := filepath.Join(t.TempDir(), "test.log") |
nothing calls this directly
no test coverage detected