fix: more env version write tests

See toolshed/organising#661
This commit is contained in:
2025-01-02 19:42:55 +01:00
parent f07c64f7b8
commit 3a71dc47f8
15 changed files with 661 additions and 45 deletions

View File

@ -105,7 +105,7 @@ func (r Recipe) IsChaosCommit(version string) (bool, error) {
isChaosCommit = true
}
return true, nil
return isChaosCommit, nil
}
// EnsureVersion checks whether a specific version exists for a recipe.

View File

@ -125,6 +125,20 @@ type Features struct {
SSO string `json:"sso"`
}
func GetEnvVersionRaw(name string) (string, error) {
var version string
if strings.Contains(name, ":") {
split := strings.Split(name, ":")
if len(split) > 2 {
return version, fmt.Errorf("version seems invalid: %s", name)
}
version = split[1]
}
return version, nil
}
func Get(name string) Recipe {
version := ""
if strings.Contains(name, ":") {

View File

@ -110,3 +110,11 @@ func TestDirtyMarkerRemoved(t *testing.T) {
r := Get("abra-test-recipe:1e83340e+U")
assert.Equal(t, "1e83340e", r.EnvVersion)
}
func TestGetEnvVersionRaw(t *testing.T) {
v, err := GetEnvVersionRaw("abra-test-recipe:1e83340e+U")
if err != nil {
t.Fatal(err)
}
assert.Equal(t, "1e83340e+U", v)
}