forked from toolshed/abra
test: ensure catalogue is cloned
This commit is contained in:
parent
b53fd2689c
commit
892f6c0730
@ -14,8 +14,8 @@ import (
|
|||||||
"coopcloud.tech/abra/cli/recipe"
|
"coopcloud.tech/abra/cli/recipe"
|
||||||
"coopcloud.tech/abra/cli/server"
|
"coopcloud.tech/abra/cli/server"
|
||||||
"coopcloud.tech/abra/pkg/autocomplete"
|
"coopcloud.tech/abra/pkg/autocomplete"
|
||||||
|
cataloguePkg "coopcloud.tech/abra/pkg/catalogue"
|
||||||
"coopcloud.tech/abra/pkg/config"
|
"coopcloud.tech/abra/pkg/config"
|
||||||
"coopcloud.tech/abra/pkg/git"
|
|
||||||
"coopcloud.tech/abra/pkg/web"
|
"coopcloud.tech/abra/pkg/web"
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
"github.com/urfave/cli"
|
"github.com/urfave/cli"
|
||||||
@ -184,13 +184,9 @@ func newAbraApp(version, commit string) *cli.App {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if _, err := os.Stat(config.CATALOGUE_DIR); os.IsNotExist(err) {
|
if err := cataloguePkg.EnsureCatalogue(); err != nil {
|
||||||
url := fmt.Sprintf("%s/%s.git", config.REPOS_BASE_URL, config.CATALOGUE_JSON_REPO_NAME)
|
|
||||||
logrus.Warnf("local recipe catalogue is missing, retrieving now")
|
|
||||||
if err := git.Clone(config.CATALOGUE_DIR, url); err != nil {
|
|
||||||
logrus.Fatal(err)
|
logrus.Fatal(err)
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
logrus.Debugf("abra version %s, commit %s", version, commit)
|
logrus.Debugf("abra version %s, commit %s", version, commit)
|
||||||
|
|
||||||
|
@ -56,6 +56,7 @@ var CatalogueSkipList = map[string]bool{
|
|||||||
func EnsureCatalogue() error {
|
func EnsureCatalogue() error {
|
||||||
catalogueDir := path.Join(config.ABRA_DIR, "catalogue")
|
catalogueDir := path.Join(config.ABRA_DIR, "catalogue")
|
||||||
if _, err := os.Stat(catalogueDir); err != nil && os.IsNotExist(err) {
|
if _, err := os.Stat(catalogueDir); err != nil && os.IsNotExist(err) {
|
||||||
|
logrus.Warnf("local recipe catalogue is missing, retrieving now")
|
||||||
url := fmt.Sprintf("%s/%s.git", config.REPOS_BASE_URL, config.CATALOGUE_JSON_REPO_NAME)
|
url := fmt.Sprintf("%s/%s.git", config.REPOS_BASE_URL, config.CATALOGUE_JSON_REPO_NAME)
|
||||||
if err := gitPkg.Clone(catalogueDir, url); err != nil {
|
if err := gitPkg.Clone(catalogueDir, url); err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -3,10 +3,15 @@ package recipe
|
|||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"coopcloud.tech/abra/pkg/catalogue"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestGetVersionLabelLocalDoesNotUseTimeoutLabel(t *testing.T) {
|
func TestGetVersionLabelLocalDoesNotUseTimeoutLabel(t *testing.T) {
|
||||||
|
if err := catalogue.EnsureCatalogue(); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
offline := true
|
offline := true
|
||||||
recipe, err := Get("traefik", offline)
|
recipe, err := Get("traefik", offline)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -4,6 +4,7 @@ import (
|
|||||||
"path"
|
"path"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"coopcloud.tech/abra/pkg/catalogue"
|
||||||
"coopcloud.tech/abra/pkg/config"
|
"coopcloud.tech/abra/pkg/config"
|
||||||
"coopcloud.tech/abra/pkg/recipe"
|
"coopcloud.tech/abra/pkg/recipe"
|
||||||
"coopcloud.tech/abra/pkg/upstream/stack"
|
"coopcloud.tech/abra/pkg/upstream/stack"
|
||||||
@ -12,6 +13,10 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func TestReadSecretsConfig(t *testing.T) {
|
func TestReadSecretsConfig(t *testing.T) {
|
||||||
|
if err := catalogue.EnsureCatalogue(); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
offline := true
|
offline := true
|
||||||
recipe, err := recipe.Get("matrix-synapse", offline)
|
recipe, err := recipe.Get("matrix-synapse", offline)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user