mirror of
https://github.com/portainer/portainer.git
synced 2025-07-19 05:19:39 +02:00
chore(ci): run lint and test on all pkgs [EE-6201] (#10481)
This commit is contained in:
parent
2e15cad048
commit
82951093b5
13 changed files with 35 additions and 66 deletions
|
@ -2,7 +2,6 @@ package compose_test
|
|||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"log"
|
||||
"os"
|
||||
|
@ -13,12 +12,11 @@ import (
|
|||
|
||||
"github.com/portainer/portainer/pkg/libstack"
|
||||
"github.com/portainer/portainer/pkg/libstack/compose"
|
||||
"github.com/portainer/portainer/pkg/testhelpers"
|
||||
)
|
||||
|
||||
func checkPrerequisites(t *testing.T) {
|
||||
if _, err := os.Stat("docker-compose"); errors.Is(err, os.ErrNotExist) {
|
||||
t.Fatal("docker-compose binary not found, please run download.sh and re-run this suite")
|
||||
}
|
||||
testhelpers.IntegrationTest(t)
|
||||
}
|
||||
|
||||
func Test_UpAndDown(t *testing.T) {
|
||||
|
@ -31,7 +29,7 @@ func Test_UpAndDown(t *testing.T) {
|
|||
services:
|
||||
busybox:
|
||||
image: "alpine:3.7"
|
||||
container_name: "test_container_one"
|
||||
container_name: "binarytest_container_one"
|
||||
`
|
||||
|
||||
const overrideComposeFileContent = `
|
||||
|
@ -39,10 +37,10 @@ func Test_UpAndDown(t *testing.T) {
|
|||
services:
|
||||
busybox:
|
||||
image: "alpine:latest"
|
||||
container_name: "test_container_two"
|
||||
container_name: "binarytest_container_two"
|
||||
`
|
||||
|
||||
const composeContainerName = "test_container_two"
|
||||
const composeContainerName = "binarytest_container_two"
|
||||
|
||||
dir := t.TempDir()
|
||||
|
||||
|
@ -57,8 +55,13 @@ func Test_UpAndDown(t *testing.T) {
|
|||
}
|
||||
|
||||
ctx := context.Background()
|
||||
projectName := "binarytest"
|
||||
|
||||
err = deployer.Deploy(ctx, []string{filePathOriginal, filePathOverride}, libstack.DeployOptions{})
|
||||
err = deployer.Deploy(ctx, []string{filePathOriginal, filePathOverride}, libstack.DeployOptions{
|
||||
Options: libstack.Options{
|
||||
ProjectName: projectName,
|
||||
},
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
@ -67,7 +70,7 @@ func Test_UpAndDown(t *testing.T) {
|
|||
t.Fatal("container should exist")
|
||||
}
|
||||
|
||||
err = deployer.Remove(ctx, "", []string{filePathOriginal, filePathOverride}, libstack.Options{})
|
||||
err = deployer.Remove(ctx, projectName, []string{filePathOriginal, filePathOverride}, libstack.Options{})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
|
|
@ -1,25 +0,0 @@
|
|||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
PLATFORM=$(go env GOOS)
|
||||
ARCH=$(go env GOARCH)
|
||||
COMPOSE_VERSION=v2.5.1
|
||||
|
||||
|
||||
if [[ ${ARCH} == "amd64" ]]; then
|
||||
ARCH="x86_64"
|
||||
elif [[ ${ARCH} == "arm" ]]; then
|
||||
ARCH="armv7"
|
||||
elif [[ ${ARCH} == "arm64" ]]; then
|
||||
ARCH="aarch64"
|
||||
fi
|
||||
|
||||
|
||||
if [[ "$PLATFORM" == "windows" ]]; then
|
||||
wget --tries=3 --waitretry=30 --quiet -O "docker-compose.exe" "https://github.com/docker/compose/releases/download/$COMPOSE_VERSION/docker-compose-windows-${ARCH}.exe"
|
||||
chmod +x "docker-compose.exe"
|
||||
else
|
||||
wget --tries=3 --waitretry=30 --quiet -O "docker-compose" "https://github.com/docker/compose/releases/download/$COMPOSE_VERSION/docker-compose-${PLATFORM}-${ARCH}"
|
||||
chmod +x "docker-compose"
|
||||
fi
|
||||
|
|
@ -66,15 +66,15 @@ func Test_UpAndDown(t *testing.T) {
|
|||
services:
|
||||
busybox:
|
||||
image: "alpine:3.7"
|
||||
container_name: "test_container_one"`
|
||||
container_name: "plugintest_container_one"`
|
||||
|
||||
const overrideComposeFileContent = `version: "3.9"
|
||||
services:
|
||||
busybox:
|
||||
image: "alpine:latest"
|
||||
container_name: "test_container_two"`
|
||||
container_name: "plugintest_container_two"`
|
||||
|
||||
const composeContainerName = "test_container_two"
|
||||
const composeContainerName = "plugintest_container_two"
|
||||
|
||||
w := setup(t)
|
||||
|
||||
|
@ -90,8 +90,14 @@ services:
|
|||
t.Fatal(err)
|
||||
}
|
||||
|
||||
projectName := "plugintest"
|
||||
|
||||
ctx := context.Background()
|
||||
err = w.Deploy(ctx, []string{filePathOriginal, filePathOverride}, libstack.DeployOptions{})
|
||||
err = w.Deploy(ctx, []string{filePathOriginal, filePathOverride}, libstack.DeployOptions{
|
||||
Options: libstack.Options{
|
||||
ProjectName: projectName,
|
||||
},
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
@ -100,7 +106,7 @@ services:
|
|||
t.Fatal("container should exist")
|
||||
}
|
||||
|
||||
err = w.Remove(ctx, "", []string{filePathOriginal, filePathOverride}, libstack.Options{})
|
||||
err = w.Remove(ctx, projectName, []string{filePathOriginal, filePathOverride}, libstack.Options{})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ package composeplugin
|
|||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"time"
|
||||
|
@ -143,7 +144,7 @@ func (wrapper *PluginWrapper) WaitForStatus(ctx context.Context, name string, st
|
|||
var svc service
|
||||
|
||||
err := dec.Decode(&svc)
|
||||
if err == io.EOF {
|
||||
if errors.Is(err, io.EOF) {
|
||||
break
|
||||
}
|
||||
if err != nil {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue