Compare commits
5 Commits
a150f227bc
...
82bcaaa86f
Author | SHA1 | Date |
---|---|---|
Rich M | 82bcaaa86f | |
decentral1se | f18f0b6f82 | |
decentral1se | 892f6c0730 | |
decentral1se | b53fd2689c | |
decentral1se | 906bf65d47 |
|
@ -16,6 +16,8 @@ steps:
|
|||
|
||||
- name: make test
|
||||
image: golang:1.21
|
||||
environment:
|
||||
ABRA_DIR: "/root/.abra"
|
||||
commands:
|
||||
- make test
|
||||
depends_on:
|
||||
|
|
10
cli/cli.go
10
cli/cli.go
|
@ -14,8 +14,8 @@ import (
|
|||
"coopcloud.tech/abra/cli/recipe"
|
||||
"coopcloud.tech/abra/cli/server"
|
||||
"coopcloud.tech/abra/pkg/autocomplete"
|
||||
cataloguePkg "coopcloud.tech/abra/pkg/catalogue"
|
||||
"coopcloud.tech/abra/pkg/config"
|
||||
"coopcloud.tech/abra/pkg/git"
|
||||
"coopcloud.tech/abra/pkg/web"
|
||||
"github.com/sirupsen/logrus"
|
||||
"github.com/urfave/cli"
|
||||
|
@ -184,12 +184,8 @@ func newAbraApp(version, commit string) *cli.App {
|
|||
}
|
||||
}
|
||||
|
||||
if _, err := os.Stat(config.CATALOGUE_DIR); os.IsNotExist(err) {
|
||||
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)
|
||||
}
|
||||
if err := cataloguePkg.EnsureCatalogue(); err != nil {
|
||||
logrus.Fatal(err)
|
||||
}
|
||||
|
||||
logrus.Debugf("abra version %s, commit %s", version, commit)
|
||||
|
|
|
@ -56,6 +56,7 @@ var CatalogueSkipList = map[string]bool{
|
|||
func EnsureCatalogue() error {
|
||||
catalogueDir := path.Join(config.ABRA_DIR, "catalogue")
|
||||
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)
|
||||
if err := gitPkg.Clone(catalogueDir, url); err != nil {
|
||||
return err
|
||||
|
|
|
@ -0,0 +1,38 @@
|
|||
package dns
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestEnsureDomainsResolveSameIPv4(t *testing.T) {
|
||||
tests := []struct {
|
||||
domainName string
|
||||
serverName string
|
||||
shouldValidate bool
|
||||
}{
|
||||
// NOTE(d1): DNS records get checked, so use something we control. if
|
||||
// you're here because of a failing test, try `dig +short <domain>` to
|
||||
// ensure stuff matches first!
|
||||
{"docs.coopcloud.tech", "coopcloud.tech", true},
|
||||
{"docs.coopcloud.tech", "swarm.autonomic.zone", true},
|
||||
|
||||
// NOTE(d1): special case handling for "--local"
|
||||
{"", "default", true},
|
||||
{"", "local", true},
|
||||
|
||||
{"", "", false},
|
||||
{"123", "", false},
|
||||
}
|
||||
|
||||
for _, test := range tests {
|
||||
_, err := EnsureDomainsResolveSameIPv4(test.domainName, test.serverName)
|
||||
if err != nil && test.shouldValidate {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
if err == nil && !test.shouldValidate {
|
||||
t.Fatal(fmt.Errorf("should have failed but did not: %v", test))
|
||||
}
|
||||
}
|
||||
}
|
|
@ -3,10 +3,15 @@ package recipe
|
|||
import (
|
||||
"testing"
|
||||
|
||||
"coopcloud.tech/abra/pkg/catalogue"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestGetVersionLabelLocalDoesNotUseTimeoutLabel(t *testing.T) {
|
||||
if err := catalogue.EnsureCatalogue(); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
offline := true
|
||||
recipe, err := Get("traefik", offline)
|
||||
if err != nil {
|
||||
|
|
|
@ -4,6 +4,7 @@ import (
|
|||
"path"
|
||||
"testing"
|
||||
|
||||
"coopcloud.tech/abra/pkg/catalogue"
|
||||
"coopcloud.tech/abra/pkg/config"
|
||||
"coopcloud.tech/abra/pkg/recipe"
|
||||
"coopcloud.tech/abra/pkg/upstream/stack"
|
||||
|
@ -12,6 +13,10 @@ import (
|
|||
)
|
||||
|
||||
func TestReadSecretsConfig(t *testing.T) {
|
||||
if err := catalogue.EnsureCatalogue(); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
offline := true
|
||||
recipe, err := recipe.Get("matrix-synapse", offline)
|
||||
if err != nil {
|
||||
|
|
|
@ -272,6 +272,21 @@ teardown(){
|
|||
assert_success
|
||||
}
|
||||
|
||||
@test "ensure domain is checked" {
|
||||
appDomain="custom-html.DOESNTEXIST"
|
||||
|
||||
run $ABRA app new custom-html \
|
||||
--no-input \
|
||||
--server "$TEST_SERVER" \
|
||||
--domain "$appDomain"
|
||||
assert_success
|
||||
assert_exists "$ABRA_DIR/servers/$TEST_SERVER/$appDomain.env"
|
||||
|
||||
run $ABRA app deploy "$appDomain" --no-input
|
||||
assert_failure
|
||||
assert_output --partial 'no such host'
|
||||
}
|
||||
|
||||
# bats test_tags=slow
|
||||
@test "skip domain check when requested" {
|
||||
run $ABRA app deploy "$TEST_APP_DOMAIN" \
|
||||
|
|
Loading…
Reference in New Issue