(t *testing.T)
| 147 | } |
| 148 | |
| 149 | func TestReadError(t *testing.T) { |
| 150 | // confirm blobNotFoundError converts to ErrDoesNotExist |
| 151 | blobNotFoundError := blobStorageError(string(bloberror.BlobNotFound)) |
| 152 | err := readError(blobNotFoundError) |
| 153 | require.Equal(t, backend.ErrDoesNotExist, err) |
| 154 | |
| 155 | // wrap blob not found error and confirm it still converts to ErrDoesNotExist |
| 156 | wrappedBlobNotFoundError := fmt.Errorf("wrap: %w", blobNotFoundError) |
| 157 | err = readError(wrappedBlobNotFoundError) |
| 158 | require.Equal(t, backend.ErrDoesNotExist, err) |
| 159 | |
| 160 | // rando error is not returned as ErrDoesNotExist |
| 161 | randoError := errors.New("blerg") |
| 162 | err = readError(randoError) |
| 163 | require.NotEqual(t, backend.ErrDoesNotExist, err) |
| 164 | |
| 165 | // other azure error is not returned as ErrDoesNotExist |
| 166 | otherAzureError := blobStorageError(string(bloberror.InternalError)) |
| 167 | err = readError(otherAzureError) |
| 168 | require.NotEqual(t, backend.ErrDoesNotExist, err) |
| 169 | } |
| 170 | |
| 171 | func blobStorageError(serviceCode string) error { |
| 172 | resp := &http.Response{ |
nothing calls this directly
no test coverage detected