-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
56 additions
and
8 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
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
48 changes: 48 additions & 0 deletions
48
api/ocm/extensions/repositories/genericocireg/genericocireg_test.go
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 |
---|---|---|
@@ -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) | ||
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) | ||
assert.Equal(t, test.expected, version) | ||
} | ||
} |
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