change signature
This commit is contained in:
Родитель
3b121ffff8
Коммит
056e4ee707
|
@ -135,14 +135,14 @@ func sameMajorVersion(majorVersion int) func(i interface{}) bool {
|
|||
}
|
||||
}
|
||||
|
||||
func GetCurrentMajorVersionFromEnv() string {
|
||||
func GetCurrentMajorVersionFromEnv() (int, error) {
|
||||
currentMajorVer := os.Getenv("PREVIOUS_MAJOR_VERSION")
|
||||
if currentMajorVer == "" {
|
||||
return "v0"
|
||||
return 0, nil
|
||||
}
|
||||
previousMajorVer, err := strconv.Atoi(strings.TrimPrefix(currentMajorVer, "v"))
|
||||
if err != nil {
|
||||
return ""
|
||||
return 0, err
|
||||
}
|
||||
return fmt.Sprintf("v%d", previousMajorVer+1)
|
||||
return previousMajorVer + 1, nil
|
||||
}
|
||||
|
|
|
@ -43,12 +43,14 @@ func TestSkipIfNoTagsWithinMajorVersion(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestGetCurrentMajorVersionFromEnv_default(t *testing.T) {
|
||||
majorVersionFromEnv := GetCurrentMajorVersionFromEnv()
|
||||
assert.Equal(t, "v0", majorVersionFromEnv)
|
||||
majorVersionFromEnv, err := GetCurrentMajorVersionFromEnv()
|
||||
assert.Nil(t, err)
|
||||
assert.Equal(t, 0, majorVersionFromEnv)
|
||||
}
|
||||
|
||||
func TestGetCurrentMajorVersionFromEnv_basic(t *testing.T) {
|
||||
os.Setenv("PREVIOUS_MAJOR_VERSION", "v0")
|
||||
majorVersionFromEnv := GetCurrentMajorVersionFromEnv()
|
||||
assert.Equal(t, "v1", majorVersionFromEnv)
|
||||
majorVersionFromEnv, err := GetCurrentMajorVersionFromEnv()
|
||||
assert.Nil(t, err)
|
||||
assert.Equal(t, 1, majorVersionFromEnv)
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче