feat: remote recipes

This commit is contained in:
2024-07-08 15:13:13 +02:00
parent 1a3ec7a107
commit d7a870b887
11 changed files with 107 additions and 56 deletions

View File

@ -1,11 +1,60 @@
package recipe
import (
"path"
"testing"
"coopcloud.tech/abra/pkg/config"
"github.com/google/go-cmp/cmp"
"github.com/stretchr/testify/assert"
)
func TestGet(t *testing.T) {
cfg := config.LoadAbraConfig()
testcases := []struct {
name string
recipe Recipe
}{
{
name: "foo",
recipe: Recipe{
Name: "foo",
Dir: path.Join(cfg.GetAbraDir(), "/recipes/foo"),
GitURL: "https://git.coopcloud.tech/coop-cloud/foo.git",
SSHURL: "ssh://git@git.coopcloud.tech:2222/coop-cloud/foo.git",
ComposePath: path.Join(cfg.GetAbraDir(), "recipes/foo/compose.yml"),
ReadmePath: path.Join(cfg.GetAbraDir(), "recipes/foo/README.md"),
SampleEnvPath: path.Join(cfg.GetAbraDir(), "recipes/foo/.env.sample"),
AbraShPath: path.Join(cfg.GetAbraDir(), "recipes/foo/abra.sh"),
},
},
{
name: "mygit.org/myorg/cool-recipe",
recipe: Recipe{
Name: "mygit.org/myorg/cool-recipe",
Dir: path.Join(cfg.GetAbraDir(), "/recipes/mygit_org_myorg_cool-recipe"),
GitURL: "https://mygit.org/myorg/cool-recipe.git",
SSHURL: "ssh://git@mygit.org/myorg/cool-recipe.git",
ComposePath: path.Join(cfg.GetAbraDir(), "recipes/mygit_org_myorg_cool-recipe/compose.yml"),
ReadmePath: path.Join(cfg.GetAbraDir(), "recipes/mygit_org_myorg_cool-recipe/README.md"),
SampleEnvPath: path.Join(cfg.GetAbraDir(), "recipes/mygit_org_myorg_cool-recipe/.env.sample"),
AbraShPath: path.Join(cfg.GetAbraDir(), "recipes/mygit_org_myorg_cool-recipe/abra.sh"),
},
},
}
for _, tc := range testcases {
t.Run(tc.name, func(t *testing.T) {
t.Setenv("ABRA_DIR", "<abraDir>")
recipe := Get(tc.name)
if diff := cmp.Diff(tc.recipe, recipe); diff != "" {
t.Errorf("Recipe mismatch (-want +got):\n%s", diff)
}
})
}
}
func TestGetVersionLabelLocalDoesNotUseTimeoutLabel(t *testing.T) {
offline := true