| 160 | } |
| 161 | |
| 162 | func TestOpenFails(t *testing.T) { |
| 163 | tests := []struct { |
| 164 | paths []string |
| 165 | }{ |
| 166 | {paths: []string{"./non-existent-dir/file"}}, // directory doesn't exist |
| 167 | {paths: []string{"stdout", "./non-existent-dir/file"}}, // directory doesn't exist |
| 168 | {paths: []string{"://foo.log"}}, // invalid URL, scheme can't begin with colon |
| 169 | {paths: []string{"mem://somewhere"}}, // scheme not registered |
| 170 | } |
| 171 | |
| 172 | for _, tt := range tests { |
| 173 | _, cleanup, err := Open(tt.paths...) |
| 174 | require.Nil(t, cleanup, "Cleanup function should be nil") |
| 175 | assert.Error(t, err, "Open with invalid URL should fail.") |
| 176 | } |
| 177 | } |
| 178 | |
| 179 | func TestOpenOtherErrors(t *testing.T) { |
| 180 | tempName := filepath.Join(t.TempDir(), "test.log") |