From 38e3f681059487a3d2be8059f1f9533c30915636 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Jochum?= Date: Wed, 4 Sep 2024 03:21:21 +0200 Subject: [PATCH] fix(tests): fix tests with dagger --- client/tests/tests.go | 12 +----------- registry/consul/scripts/pre_test.sh | 11 ++++++++--- registry/nats/scripts/pre_test.sh | 11 ++++++++--- 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/client/tests/tests.go b/client/tests/tests.go index 8a2b18d1..29b471d6 100644 --- a/client/tests/tests.go +++ b/client/tests/tests.go @@ -6,7 +6,6 @@ import ( "fmt" "net/url" "os" - "path/filepath" "time" "github.com/go-orb/go-orb/client" @@ -104,9 +103,6 @@ var ( type TestSuite struct { suite.Suite - // The path of plugins/ - PluginsRoot string - // Transports is the list of preferred transports for all requests Transports []string @@ -128,7 +124,6 @@ type TestSuite struct { func NewSuite(pluginsRoot string, transports []string, requests ...TestRequest) *TestSuite { s := new(TestSuite) - s.PluginsRoot = pluginsRoot s.Transports = transports if len(requests) == 0 { @@ -162,11 +157,6 @@ func (s *TestSuite) SetupSuite() { cURLs := []*url.URL{} - curl, err := url.Parse("file://" + filepath.Join(s.PluginsRoot, "client/tests/cmd/tests_server/config.yaml")) - s.Require().NoError(err, "while parsing a url") - - cURLs = append(cURLs, curl) - cfgData, err := config.Read(cURLs, nil) if err != nil { s.Require().NoError(err, "while parsing a config") @@ -208,7 +198,7 @@ func (s *TestSuite) SetupSuite() { // WithNumProcesses(5), // WithRunEnv("GOMAXPROCS=1"), WithRunEnv("GOMAXPROCS=" + os.Getenv("GOMAXPROCS")), - WithArgs("--config", filepath.Join(s.PluginsRoot, "client/tests/cmd/tests_server/config.yaml")), + WithArgs("--config", "../../cmd/tests_server/config.yaml"), } // if logger.Level() <= slog.LevelDebug { pro = append(pro, WithStdOut(os.Stdout), WithStdErr(os.Stderr)) diff --git a/registry/consul/scripts/pre_test.sh b/registry/consul/scripts/pre_test.sh index 2684df6d..ae96de09 100755 --- a/registry/consul/scripts/pre_test.sh +++ b/registry/consul/scripts/pre_test.sh @@ -1,9 +1,14 @@ #!/usr/bin/env bash set -e; set -o pipefail -# Import util.sh SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) -source ${SCRIPT_DIR}/../../../scripts/lib/util.sh + +# https://gist.github.com/lukechilds/a83e1d7127b78fef38c2914c4ececc3c +function get_latest_gh_release() { + curl --silent "https://api.github.com/repos/$1/releases/latest" | # Get latest release from GitHub api + grep '"tag_name":' | # Get tag line + sed -E 's/.*"([^"]+)".*/\1/' # Pluck JSON value +} GOOS=$(go env GOOS) GOARCH=$(go env GOARCH) @@ -17,7 +22,7 @@ mkdir -p "${WORKDIR}" pushd "${WORKDIR}" if [[ ! -x consul ]]; then - print_msg "Downloading curl ${VERSION}" + echo "Downloading consul ${VERSION}" curl -s -L https://releases.hashicorp.com/consul/${VERSION}/consul_${VERSION}_${GOOS}_${GOARCH}.zip -o consul.zip unzip consul.zip 1>/dev/null diff --git a/registry/nats/scripts/pre_test.sh b/registry/nats/scripts/pre_test.sh index 1a4ab305..1796e695 100755 --- a/registry/nats/scripts/pre_test.sh +++ b/registry/nats/scripts/pre_test.sh @@ -1,9 +1,14 @@ #!/usr/bin/env bash set -e; set -o pipefail -# Import util.sh SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) -source ${SCRIPT_DIR}/../../../scripts/lib/util.sh + +# https://gist.github.com/lukechilds/a83e1d7127b78fef38c2914c4ececc3c +function get_latest_gh_release() { + curl --silent "https://api.github.com/repos/$1/releases/latest" | # Get latest release from GitHub api + grep '"tag_name":' | # Get tag line + sed -E 's/.*"([^"]+)".*/\1/' # Pluck JSON value +} GOOS=$(go env GOOS) GOARCH=$(go env GOARCH) @@ -17,7 +22,7 @@ mkdir -p "${WORKDIR}" pushd "${WORKDIR}" if [[ ! -x nats-server ]]; then - print_msg "Downloading NATS ${VERSION}" + echo "Downloading NATS ${VERSION}" curl -s -L https://github.com/nats-io/nats-server/releases/download/${VERSION}/${ZIPFILE}.zip -o nats.zip unzip nats.zip "*/nats-server" 1>/dev/null