Skip to content

Commit

Permalink
change tests
Browse files Browse the repository at this point in the history
Signed-off-by: Billy Zha <[email protected]>
  • Loading branch information
qweeah committed Dec 23, 2022
1 parent 3804485 commit 9e37975
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 14 deletions.
4 changes: 0 additions & 4 deletions cmd/oras/internal/fileref/unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,6 @@ import (

// Parse parses file reference on unix.
func Parse(reference string, defaultMediaType string) (filePath, mediaType string, err error) {
if reference == "" {
return "", "", nil
}

filePath = reference
mediaType = defaultMediaType
i := strings.LastIndex(reference, ":")
Expand Down
2 changes: 1 addition & 1 deletion cmd/oras/internal/fileref/unix_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ func TestParse(t *testing.T) {
wantErr bool
}{

{"no input", args{"", ""}, "", "", false},
{"no input", args{"", ""}, "", "", true},
{"empty file name and media type", args{":", ""}, "", "", true},
{"empty file name with media type", args{":a", "b"}, "", "", true},
}
Expand Down
5 changes: 0 additions & 5 deletions cmd/oras/internal/fileref/windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,6 @@ import (

// Parse parses file reference on windows.
func Parse(reference string, defaultMediaType string) (filePath, mediaType string, err error) {
if reference == "" {
// no input
return "", "", nil
}

filePath, mediaType = doParse(reference, defaultMediaType)
if filePath == "" {
return "", "", fmt.Errorf("found empty file path in %q", reference)
Expand Down
2 changes: 1 addition & 1 deletion cmd/oras/internal/fileref/windows_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ func TestParse(t *testing.T) {
wantMediatype string
wantErr bool
}{
{"no input", args{"", ""}, "", "", false},
{"no input", args{"", ""}, "", "", true},
{"empty file name", args{":", ""}, "", "", true},
{"reserved character1 in file name", args{"<", "a"}, "", "", true},
{"reserved character2 in file name", args{">", "a"}, "", "", true},
Expand Down
9 changes: 6 additions & 3 deletions cmd/oras/pull.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,12 @@ func runPull(opts pullOptions) error {
// Copy Options
copyOptions := oras.DefaultCopyOptions
copyOptions.Concurrency = opts.concurrency
configPath, configMediaType, err := fileref.Parse(opts.ManifestConfigRef, "")
if err != nil {
return err
var configPath, configMediaType string
if opts.ManifestConfigRef != "" {
configPath, configMediaType, err = fileref.Parse(opts.ManifestConfigRef, "")
if err != nil {
return err
}
}
if targetPlatform != nil {
copyOptions.WithTargetPlatform(targetPlatform)
Expand Down

0 comments on commit 9e37975

Please sign in to comment.