-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix/remove go version dependency (#36)
* Remove hashicorp/go-version dependency * Adds Fossa analysis to the actions workflow * Fixes warning related to the actions/setup-go step * Add tests for VersionInfo methods and simplify comparisons
- Loading branch information
1 parent
c217f05
commit 6a02fa7
Showing
7 changed files
with
178 additions
and
14 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
package utils | ||
|
||
import ( | ||
"github.com/stretchr/testify/assert" | ||
"testing" | ||
) | ||
|
||
func Test_VersionInfo_tryParseVersionInfo_valid_semantic_version_expression_with_prefix_does_not_return_err(t *testing.T) { | ||
|
||
// Arrange | ||
const version = "v0.1.0" | ||
|
||
// Act | ||
actual, err := tryParseVersionInfo(version) | ||
|
||
// Assert | ||
assert.NoError(t, err) | ||
assert.NotNil(t, actual) | ||
assert.Equal(t, "0.1.0", actual.String()) | ||
} | ||
|
||
func Test_VersionInfo_tryParseVersionInfo_valid_semantic_version_expression_no_prefix_does_not_return_err(t *testing.T) { | ||
|
||
// Arrange | ||
const version = "0.1.0" | ||
|
||
// Act | ||
actual, err := tryParseVersionInfo(version) | ||
|
||
// Assert | ||
assert.NoError(t, err) | ||
assert.NotNil(t, actual) | ||
assert.Equal(t, "0.1.0", actual.String()) | ||
} | ||
|
||
func Test_VersionInfo_tryParseVersionInfo_invalid_semantic_version_expression_returns_err(t *testing.T) { | ||
|
||
// Arrange | ||
const version = "a.b.c" | ||
|
||
// Act | ||
actual, err := tryParseVersionInfo(version) | ||
|
||
// Assert | ||
assert.Error(t, err) | ||
assert.Nil(t, actual) | ||
} | ||
|
||
func Test_VersionInfo_LessThan(t *testing.T) { | ||
|
||
// Arrange | ||
const a = "v0.1.0" | ||
const b = "v0.2.0" | ||
|
||
version, _ := tryParseVersionInfo(a) | ||
otherVersion, _ := tryParseVersionInfo(b) | ||
|
||
// Act | ||
actual := version.LessThan(*otherVersion) | ||
|
||
// Assert | ||
assert.True(t, actual) | ||
} | ||
|
||
func Test_VersionInfo_LessThanOrEqual(t *testing.T) { | ||
|
||
// Arrange | ||
const a = "v0.1.0" | ||
b := []string{"v0.2.0", "v0.1.0"} | ||
|
||
version, _ := tryParseVersionInfo(a) | ||
|
||
// Act | ||
for _, v := range b { | ||
otherVersion, _ := tryParseVersionInfo(v) | ||
|
||
actual := version.LessThanOrEqual(*otherVersion) | ||
|
||
// Assert | ||
assert.True(t, actual) | ||
} | ||
} | ||
|
||
func Test_VersionInfo_Equal(t *testing.T) { | ||
|
||
// Arrange | ||
const a = "v0.1.0" | ||
const b = "v0.1.0" | ||
|
||
version, _ := tryParseVersionInfo(a) | ||
otherVersion, _ := tryParseVersionInfo(b) | ||
|
||
// Act | ||
|
||
actual := version.Equal(*otherVersion) | ||
|
||
// Assert | ||
assert.True(t, actual) | ||
} |