Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
Signed-off-by: Lixia (Sylvia) Lei <[email protected]>
  • Loading branch information
Wwwsylvia committed Jul 12, 2023
1 parent 5332f5c commit 5c8d440
Showing 1 changed file with 21 additions and 6 deletions.
27 changes: 21 additions & 6 deletions pack_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import (
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
"oras.land/oras-go/v2/content"
"oras.land/oras-go/v2/content/memory"
"oras.land/oras-go/v2/errdef"
"oras.land/oras-go/v2/internal/spec"
)

Expand Down Expand Up @@ -239,8 +240,8 @@ func Test_Pack_InvalidDateTimeFormat(t *testing.T) {
}
artifactType := "application/vnd.test"
_, err := Pack(ctx, s, artifactType, nil, opts)
if err == nil || !errors.Is(err, ErrInvalidDateTimeFormat) {
t.Errorf("Oras.Pack() error = %v, wantErr = %v", err, ErrInvalidDateTimeFormat)
if wantErr := ErrInvalidDateTimeFormat; !errors.Is(err, wantErr) {
t.Errorf("Oras.Pack() error = %v, wantErr = %v", err, wantErr)
}
}

Expand Down Expand Up @@ -510,8 +511,8 @@ func Test_Pack_ImageLegacy_InvalidDateTimeFormat(t *testing.T) {
},
}
_, err := Pack(ctx, s, "", nil, opts)
if err == nil || !errors.Is(err, ErrInvalidDateTimeFormat) {
t.Errorf("Oras.Pack() error = %v, wantErr = %v", err, ErrInvalidDateTimeFormat)
if wantErr := ErrInvalidDateTimeFormat; !errors.Is(err, wantErr) {
t.Errorf("Oras.Pack() error = %v, wantErr = %v", err, wantErr)
}
}

Expand Down Expand Up @@ -850,8 +851,8 @@ func Test_Pack_Image_InvalidDateTimeFormat(t *testing.T) {
},
}
_, err := Pack(ctx, s, "", nil, opts)
if err == nil || !errors.Is(err, ErrInvalidDateTimeFormat) {
t.Errorf("Oras.Pack() error = %v, wantErr = %v", err, ErrInvalidDateTimeFormat)
if wantErr := ErrInvalidDateTimeFormat; !errors.Is(err, wantErr) {
t.Errorf("Oras.Pack() error = %v, wantErr = %v", err, wantErr)
}
}

Expand Down Expand Up @@ -927,3 +928,17 @@ func Test_Pack_DefaultPackOptions(t *testing.T) {
t.Errorf("got descriptor annotations = %v, want %v", manifestDesc.Annotations, want)
}
}

func Test_Pack_UnsupportedPackManifestType(t *testing.T) {
s := memory.New()

ctx := context.Background()
opts := PackOptions{
PackImageManifest: true,
PackManifestType: -1,
}
_, err := Pack(ctx, s, "", nil, opts)
if wantErr := errdef.ErrUnsupported; !errors.Is(err, wantErr) {
t.Errorf("Oras.Pack() error = %v, wantErr = %v", err, wantErr)
}
}

0 comments on commit 5c8d440

Please sign in to comment.