forked from containers/image
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ociarchive: Add new
ArchiveFileNotFoundError
This is for containers/skopeo#2114 which is in turn a dependency of coreos/rpm-ostree#4598 Basically I want to map ENOENT to a clear error, because the build tooling wants to treat "target image is not present" differently from "DNS lookup failed" or "we got EPERM". There's a bit of code motion here because we need to move the `os.Open()` call before creating a temporary directory. Signed-off-by: Colin Walters <[email protected]>
- Loading branch information
Showing
3 changed files
with
47 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,26 @@ | ||
package archive | ||
|
||
import "github.com/containers/image/v5/internal/private" | ||
import ( | ||
"path/filepath" | ||
"testing" | ||
|
||
"github.com/containers/image/v5/internal/private" | ||
"github.com/containers/image/v5/types" | ||
"github.com/stretchr/testify/assert" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
var _ private.ImageSource = (*ociArchiveImageSource)(nil) | ||
|
||
func TestNewImageSourceNotFound(t *testing.T) { | ||
emptyDir := t.TempDir() | ||
sysctx := types.SystemContext{BlobInfoCacheDir: emptyDir} | ||
archivePath := filepath.Join(emptyDir, "foo.ociarchive") | ||
imgref, err := ParseReference(archivePath) | ||
require.NoError(t, err) | ||
_, err = LoadManifestDescriptorWithContext(&sysctx, imgref) | ||
assert.NotNil(t, err) | ||
var aerr ArchiveFileNotFoundError | ||
assert.ErrorAs(t, err, &aerr) | ||
assert.Equal(t, aerr.path, archivePath) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters