Skip to content

Commit

Permalink
Extend tests for distribution (#717)
Browse files Browse the repository at this point in the history
  • Loading branch information
phillebaba authored Jan 28, 2025
2 parents 5305285 + d9f9d54 commit 3d77960
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Added

- [#717](https://github.com/spegel-org/spegel/pull/717) Extend tests for distribution.

### Changed

### Deprecated
Expand Down
44 changes: 44 additions & 0 deletions pkg/registry/distribution_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,42 @@ import (
"github.com/stretchr/testify/require"
)

func TestReference(t *testing.T) {
t.Parallel()

tests := []struct {
name string
refName string
expected bool
}{
{
name: "with latest tag",
refName: "ghcr.io/spegel-org/spegel:latest",
expected: true,
},
{
name: "no latest tag",
refName: "ghcr.io/spegel-org/spegel:v1.0.0",
expected: false,
},
{
name: "empty name",
refName: "",
expected: false,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
t.Parallel()

ref := reference{
name: tt.refName,
}
require.Equal(t, tt.expected, ref.hasLatestTag())
})
}
}

func TestParsePathComponents(t *testing.T) {
t.Parallel()

Expand All @@ -26,6 +62,14 @@ func TestParsePathComponents(t *testing.T) {
expectedDgst: "",
expectedRefKind: referenceKindManifest,
},
{
name: "valid manifest digest",
registry: "docker.io",
path: "/v2/library/nginx/manifests/sha256:0a404ca8e119d061cdb2dceee824c914cdc69b31bc7b5956ef5a520436a80d39",
expectedName: "",
expectedDgst: digest.Digest("sha256:0a404ca8e119d061cdb2dceee824c914cdc69b31bc7b5956ef5a520436a80d39"),
expectedRefKind: referenceKindManifest,
},
{
name: "valid blob digest",
registry: "docker.io",
Expand Down

0 comments on commit 3d77960

Please sign in to comment.