Skip to content

Commit

Permalink
fix more
Browse files Browse the repository at this point in the history
  • Loading branch information
hilmarf committed Jan 8, 2025
1 parent ac5631e commit a1c2189
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 8 deletions.
2 changes: 1 addition & 1 deletion api/ocm/compdesc/normalizations/legacy/legacy.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ var (

// DefaultingOfVersionIntoExtraIdentity normalizes the extra identity of the resources.
// It sets the version of the resource, reference or source as extra identity field if the combination of name+extra identity
// is the same for multiple items. However, the last item in the list will not be updated as it is unique wihout this.
// is the same for multiple items. However, the last item in the list will not be updated as it is unique without this.
//
// TODO: To be removed once v1 + v2 are removed.
//
Expand Down
4 changes: 2 additions & 2 deletions api/ocm/extensions/accessmethods/ocm/cli_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ var _ = Describe("OCM access CLI Test Environment", func() {
Expect(h).NotTo(BeNil())
Expect(h.GetName()).To(Equal(ocm.Type))

ot := h.OptionTypes()
Expect(len(ot)).To(Equal(4))
optionTypes := h.OptionTypes()
Expect(len(optionTypes)).To(Equal(4))

opts := h.CreateOptions()
Expect(sliceutils.Transform(opts.Options(), transformer.GetName[flagsets.Option, string])).To(ConsistOf(
Expand Down
4 changes: 2 additions & 2 deletions api/ocm/extensions/accessmethods/options/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ type option struct {
}

func (o *option) Equal(t flagsets.ConfigOptionType) bool {
if ot, ok := t.(*option); ok {
return o.valueType == ot.valueType && o.GetName() == ot.GetName()
if optionType, ok := t.(*option); ok {
return o.valueType == optionType.valueType && o.GetName() == optionType.GetName()
}
return false
}
Expand Down
4 changes: 2 additions & 2 deletions api/ocm/extensions/accessmethods/plugin/cmd_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ var _ = Describe("Add with new access method", func() {
Expect(h).NotTo(BeNil())
Expect(h.GetName()).To(Equal("test"))

ot := h.OptionTypes()
Expect(len(ot)).To(Equal(2))
optionTypes := h.OptionTypes()
Expect(len(optionTypes)).To(Equal(2))

opts := h.CreateOptions()
Expect(sliceutils.Transform(opts.Options(), transformer.GetName[flagsets.Option, string])).To(ConsistOf(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package genericocireg_test

import (
"testing"

"github.com/stretchr/testify/assert"
"ocm.software/ocm/api/ocm/extensions/repositories/genericocireg"
)

func TestToTag(t *testing.T) {
tests := []struct {
version string
expected string
expectErr bool
}{
{"1.0.0", "1.0.0", false},
{"1.0.0+build", "1.0.0.build-", false},
{"1.0.0+build.metadata", "1.0.0.build-metadata", false},
{"0.0.1-20250108132333+af79499", "0.0.1-20250108132333+af79499", false},
{"invalid_version", "", true},
}

for _, test := range tests {
tag, err := genericocireg.ToTag(test.version)

Check failure on line 24 in api/ocm/extensions/repositories/genericocireg/genericocireg_test.go

View workflow job for this annotation

GitHub Actions / Run tests

undefined: genericocireg.ToTag
if test.expectErr {
assert.Error(t, err)
} else {
assert.NoError(t, err)
assert.Equal(t, test.expected, tag)
}
}
}

func TestToVersion(t *testing.T) {
tests := []struct {
tag string
expected string
}{
{"1.0.0", "1.0.0"},
{"1.0.0.build-", "1.0.0+build"},
{"1.0.0.build-metadata", "1.0.0+build.metadata"},
}

for _, test := range tests {
version := genericocireg.ToVersion(test.tag)

Check failure on line 45 in api/ocm/extensions/repositories/genericocireg/genericocireg_test.go

View workflow job for this annotation

GitHub Actions / Run tests

undefined: genericocireg.ToVersion
assert.Equal(t, test.expected, version)
}
}
2 changes: 1 addition & 1 deletion api/ocm/tools/transfer/transfer.go
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ func copyVersion(printer common.Printer, log logging.Logger, hist common.History
}
}
if ok {
// sources do not have digests fo far, so they have to copied, always.
// sources do not have digests so far, so they have to copied, always.
hint := ocmcpi.ArtifactNameHint(a, src)
notifyArtifactInfo(printer, log, "source", i, r.Meta(), hint)
err = errors.Join(err, handler.HandleTransferSource(r, m, hint, t))
Expand Down

0 comments on commit a1c2189

Please sign in to comment.