refactor: migrate e2e tests from efficientgo/e2e to capytest
This commit is contained in:
@ -19,54 +19,24 @@
|
||||
package e2etests_test
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"testing"
|
||||
|
||||
"github.com/efficientgo/e2e"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"go.alt-gnome.ru/capytest"
|
||||
)
|
||||
|
||||
func TestE2EAlrAddRepo(t *testing.T) {
|
||||
dockerMultipleRun(
|
||||
runMatrixSuite(
|
||||
t,
|
||||
"add-repo-remove-repo",
|
||||
COMMON_SYSTEMS,
|
||||
func(t *testing.T, r e2e.Runnable) {
|
||||
err := r.Exec(e2e.NewCommand(
|
||||
"sudo",
|
||||
"alr",
|
||||
"addrepo",
|
||||
"--name",
|
||||
"alr-repo",
|
||||
"--url",
|
||||
"https://gitea.plemya-x.ru/Plemya-x/alr-repo.git",
|
||||
))
|
||||
assert.NoError(t, err)
|
||||
func(t *testing.T, r capytest.Runner) {
|
||||
execShouldNoError(t, r, "sudo", "alr", "addrepo", "--name", "alr-repo", "--url", "https://gitea.plemya-x.ru/Plemya-x/alr-repo.git")
|
||||
execShouldNoError(t, r, "bash", "-c", "cat /etc/alr/alr.toml")
|
||||
execShouldNoError(t, r, "sudo", "alr", "removerepo", "--name", "alr-repo")
|
||||
|
||||
err = r.Exec(e2e.NewCommand(
|
||||
"bash",
|
||||
"-c",
|
||||
"cat /etc/alr/alr.toml",
|
||||
))
|
||||
assert.NoError(t, err)
|
||||
|
||||
err = r.Exec(e2e.NewCommand(
|
||||
"sudo",
|
||||
"alr",
|
||||
"removerepo",
|
||||
"--name",
|
||||
"alr-repo",
|
||||
))
|
||||
assert.NoError(t, err)
|
||||
|
||||
var buf bytes.Buffer
|
||||
err = r.Exec(e2e.NewCommand(
|
||||
"bash",
|
||||
"-c",
|
||||
"cat /etc/alr/alr.toml",
|
||||
), e2e.WithExecOptionStdout(&buf))
|
||||
assert.NoError(t, err)
|
||||
assert.Contains(t, buf.String(), "repo = []")
|
||||
r.Command("bash", "-c", "cat /etc/alr/alr.toml").
|
||||
ExpectStdoutContains("repo = []").
|
||||
Run(t)
|
||||
},
|
||||
)
|
||||
}
|
||||
|
@ -21,15 +21,15 @@ package e2etests_test
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/efficientgo/e2e"
|
||||
"go.alt-gnome.ru/capytest"
|
||||
)
|
||||
|
||||
func TestE2EBashCompletion(t *testing.T) {
|
||||
dockerMultipleRun(
|
||||
runMatrixSuite(
|
||||
t,
|
||||
"bash-completion",
|
||||
COMMON_SYSTEMS,
|
||||
func(t *testing.T, r e2e.Runnable) {
|
||||
func(t *testing.T, r capytest.Runner) {
|
||||
execShouldNoError(t, r, "alr", "install", "--generate-bash-completion")
|
||||
},
|
||||
)
|
||||
|
@ -19,84 +19,13 @@
|
||||
package e2etests_test
|
||||
|
||||
import (
|
||||
"crypto/sha256"
|
||||
"encoding/hex"
|
||||
"fmt"
|
||||
"io"
|
||||
"log"
|
||||
"os"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/efficientgo/e2e"
|
||||
"github.com/stretchr/testify/assert"
|
||||
|
||||
expect "github.com/tailscale/goexpect"
|
||||
"go.alt-gnome.ru/capytest"
|
||||
"go.alt-gnome.ru/capytest/providers/podman"
|
||||
)
|
||||
|
||||
// DebugWriter оборачивает io.Writer и логирует все записываемые данные.
|
||||
type DebugWriter struct {
|
||||
prefix string
|
||||
writer io.Writer
|
||||
}
|
||||
|
||||
func (d *DebugWriter) Write(p []byte) (n int, err error) {
|
||||
log.Printf("%s: Writing data: %q", d.prefix, p) // Логируем данные
|
||||
return d.writer.Write(p)
|
||||
}
|
||||
|
||||
// DebugReader оборачивает io.Reader и логирует все читаемые данные.
|
||||
type DebugReader struct {
|
||||
prefix string
|
||||
reader io.Reader
|
||||
}
|
||||
|
||||
func (d *DebugReader) Read(p []byte) (n int, err error) {
|
||||
n, err = d.reader.Read(p)
|
||||
if n > 0 {
|
||||
log.Printf("%s: Read data: %q", d.prefix, p[:n]) // Логируем данные
|
||||
}
|
||||
return n, err
|
||||
}
|
||||
|
||||
func e2eSpawn(runnable e2e.Runnable, command e2e.Command, timeout time.Duration, opts ...expect.Option) (expect.Expecter, <-chan error, error, *io.PipeWriter) {
|
||||
resCh := make(chan error)
|
||||
|
||||
// Создаем pipe для stdin и stdout
|
||||
stdinReader, stdinWriter := io.Pipe()
|
||||
stdoutReader, stdoutWriter := io.Pipe()
|
||||
|
||||
debugStdinReader := &DebugReader{prefix: "STDIN", reader: stdinReader}
|
||||
debugStdoutWriter := &DebugWriter{prefix: "STDOUT", writer: stdoutWriter}
|
||||
|
||||
go func() {
|
||||
err := runnable.Exec(
|
||||
command,
|
||||
e2e.WithExecOptionStdout(debugStdoutWriter),
|
||||
e2e.WithExecOptionStdin(debugStdinReader),
|
||||
e2e.WithExecOptionStderr(debugStdoutWriter),
|
||||
)
|
||||
|
||||
resCh <- err
|
||||
}()
|
||||
|
||||
exp, chnErr, err := expect.SpawnGeneric(&expect.GenOptions{
|
||||
In: stdinWriter,
|
||||
Out: stdoutReader,
|
||||
Wait: func() error {
|
||||
return <-resCh
|
||||
},
|
||||
Close: func() error {
|
||||
stdinWriter.Close()
|
||||
stdoutReader.Close()
|
||||
return nil
|
||||
},
|
||||
Check: func() bool { return true },
|
||||
}, timeout, expect.Verbose(true), expect.VerboseWriter(os.Stdout))
|
||||
|
||||
return exp, chnErr, err, stdinWriter
|
||||
}
|
||||
|
||||
var ALL_SYSTEMS []string = []string{
|
||||
"ubuntu-24.04",
|
||||
"alt-sisyphus",
|
||||
@ -120,71 +49,20 @@ var COMMON_SYSTEMS []string = []string{
|
||||
"ubuntu-24.04",
|
||||
}
|
||||
|
||||
func dockerMultipleRun(t *testing.T, name string, ids []string, f func(t *testing.T, runnable e2e.Runnable)) {
|
||||
t.Run(name, func(t *testing.T) {
|
||||
for _, id := range ids {
|
||||
t.Run(id, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
dockerName := fmt.Sprintf("alr-test-%s-%s", name, id)
|
||||
hash := sha256.New()
|
||||
hash.Write([]byte(dockerName))
|
||||
hashSum := hash.Sum(nil)
|
||||
hashString := hex.EncodeToString(hashSum)
|
||||
truncatedHash := hashString[:8]
|
||||
e, err := e2e.New(e2e.WithVerbose(), e2e.WithName(fmt.Sprintf("alr-%s", truncatedHash)))
|
||||
assert.NoError(t, err)
|
||||
t.Cleanup(e.Close)
|
||||
imageId := fmt.Sprintf("ghcr.io/maks1ms/alr-e2e-test-image-%s", id)
|
||||
runnable := e.Runnable(dockerName).Init(
|
||||
e2e.StartOptions{
|
||||
Image: imageId,
|
||||
Volumes: []string{
|
||||
"./alr:/tmp/alr",
|
||||
},
|
||||
Privileged: true,
|
||||
},
|
||||
)
|
||||
assert.NoError(t, e2e.StartAndWaitReady(runnable))
|
||||
err = runnable.Exec(e2e.NewCommand("/bin/alr-test-setup", "alr-install"))
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
err = runnable.Exec(e2e.NewCommand("/bin/alr-test-setup", "passwordless-sudo-setup"))
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
f(t, runnable)
|
||||
})
|
||||
}
|
||||
})
|
||||
func execShouldNoError(t *testing.T, r capytest.Runner, cmd string, args ...string) {
|
||||
t.Helper()
|
||||
r.Command(cmd, args...).ExpectSuccess().Run(t)
|
||||
}
|
||||
|
||||
func execShouldNoError(t *testing.T, r e2e.Runnable, cmd string, args ...string) {
|
||||
assert.NoError(t, r.Exec(e2e.NewCommand(cmd, args...)))
|
||||
}
|
||||
|
||||
func execShouldError(t *testing.T, r e2e.Runnable, cmd string, args ...string) {
|
||||
assert.Error(t, r.Exec(e2e.NewCommand(cmd, args...)))
|
||||
}
|
||||
|
||||
func runTestCommands(t *testing.T, r e2e.Runnable, timeout time.Duration, expects []expect.Batcher) {
|
||||
exp, _, err, _ := e2eSpawn(
|
||||
r,
|
||||
e2e.NewCommand("/bin/bash"), 25*time.Second,
|
||||
expect.Verbose(true),
|
||||
)
|
||||
assert.NoError(t, err)
|
||||
_, err = exp.ExpectBatch(
|
||||
expects,
|
||||
timeout,
|
||||
)
|
||||
assert.NoError(t, err)
|
||||
func execShouldError(t *testing.T, r capytest.Runner, cmd string, args ...string) {
|
||||
t.Helper()
|
||||
r.Command(cmd, args...).ExpectFailure().Run(t)
|
||||
}
|
||||
|
||||
const REPO_NAME_FOR_E2E_TESTS = "alr-repo"
|
||||
const REPO_URL_FOR_E2E_TESTS = "https://gitea.plemya-x.ru/Plemya-x/repo-for-tests.git"
|
||||
|
||||
func defaultPrepare(t *testing.T, r e2e.Runnable) {
|
||||
func defaultPrepare(t *testing.T, r capytest.Runner) {
|
||||
execShouldNoError(t, r,
|
||||
"sudo",
|
||||
"alr",
|
||||
@ -200,3 +78,19 @@ func defaultPrepare(t *testing.T, r e2e.Runnable) {
|
||||
"ref",
|
||||
)
|
||||
}
|
||||
|
||||
func runMatrixSuite(t *testing.T, name string, images []string, test func(t *testing.T, r capytest.Runner)) {
|
||||
t.Helper()
|
||||
for _, image := range images {
|
||||
ts := capytest.NewTestSuite(t, podman.Provider(
|
||||
podman.WithImage(fmt.Sprintf("ghcr.io/maks1ms/alr-e2e-test-image-%s", image)),
|
||||
podman.WithVolumes("./alr:/tmp/alr"),
|
||||
podman.WithPrivileged(true),
|
||||
))
|
||||
ts.BeforeEach(func(t *testing.T, r capytest.Runner) {
|
||||
execShouldNoError(t, r, "/bin/alr-test-setup", "alr-install")
|
||||
execShouldNoError(t, r, "/bin/alr-test-setup", "passwordless-sudo-setup")
|
||||
})
|
||||
ts.Run(fmt.Sprintf("%s/%s", name, image), test)
|
||||
}
|
||||
}
|
||||
|
@ -22,15 +22,15 @@ import (
|
||||
"fmt"
|
||||
"testing"
|
||||
|
||||
"github.com/efficientgo/e2e"
|
||||
"go.alt-gnome.ru/capytest"
|
||||
)
|
||||
|
||||
func TestE2EFirejailedPackage(t *testing.T) {
|
||||
dockerMultipleRun(
|
||||
runMatrixSuite(
|
||||
t,
|
||||
"firejailed-package",
|
||||
COMMON_SYSTEMS,
|
||||
func(t *testing.T, r e2e.Runnable) {
|
||||
func(t *testing.T, r capytest.Runner) {
|
||||
defaultPrepare(t, r)
|
||||
execShouldNoError(t, r, "alr", "build", "-p", fmt.Sprintf("%s/firejailed-pkg", REPO_NAME_FOR_E2E_TESTS))
|
||||
execShouldError(t, r, "alr", "build", "-p", fmt.Sprintf("%s/firejailed-pkg-incorrect", REPO_NAME_FOR_E2E_TESTS))
|
||||
|
@ -20,24 +20,15 @@ package e2etests_test
|
||||
|
||||
import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/efficientgo/e2e"
|
||||
expect "github.com/tailscale/goexpect"
|
||||
"go.alt-gnome.ru/capytest"
|
||||
)
|
||||
|
||||
func TestE2EAlrFix(t *testing.T) {
|
||||
dockerMultipleRun(
|
||||
t,
|
||||
"run-fix",
|
||||
COMMON_SYSTEMS,
|
||||
func(t *testing.T, r e2e.Runnable) {
|
||||
runTestCommands(t, r, time.Second*30, []expect.Batcher{
|
||||
&expect.BSnd{S: "alr fix\n"},
|
||||
&expect.BExp{R: `--> Done`},
|
||||
&expect.BSnd{S: "echo $?\n"},
|
||||
&expect.BExp{R: `^0\n$`},
|
||||
})
|
||||
},
|
||||
)
|
||||
runMatrixSuite(t, "run-fix", COMMON_SYSTEMS, func(t *testing.T, r capytest.Runner) {
|
||||
r.Command("alr", "fix").
|
||||
ExpectStderrContains("--> Done").
|
||||
ExpectSuccess().
|
||||
Run(t)
|
||||
})
|
||||
}
|
||||
|
@ -21,15 +21,15 @@ package e2etests_test
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/efficientgo/e2e"
|
||||
"go.alt-gnome.ru/capytest"
|
||||
)
|
||||
|
||||
func TestE2EGroupAndSummaryField(t *testing.T) {
|
||||
dockerMultipleRun(
|
||||
runMatrixSuite(
|
||||
t,
|
||||
"group-and-summary-field",
|
||||
RPM_SYSTEMS,
|
||||
func(t *testing.T, r e2e.Runnable) {
|
||||
func(t *testing.T, r capytest.Runner) {
|
||||
defaultPrepare(t, r)
|
||||
execShouldNoError(t, r, "sh", "-c", "alr search --name test-group-and-summary --format \"{{.Group.Resolved}}\" | grep ^System/Base$")
|
||||
execShouldNoError(t, r, "sh", "-c", "alr search --name test-group-and-summary --format \"{{.Summary.Resolved}}\" | grep \"^Custom summary$\"")
|
||||
|
@ -21,15 +21,15 @@ package e2etests_test
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/efficientgo/e2e"
|
||||
"go.alt-gnome.ru/capytest"
|
||||
)
|
||||
|
||||
func TestE2EIssue32Interactive(t *testing.T) {
|
||||
dockerMultipleRun(
|
||||
runMatrixSuite(
|
||||
t,
|
||||
"issue-32-interactive",
|
||||
COMMON_SYSTEMS,
|
||||
func(t *testing.T, r e2e.Runnable) {
|
||||
func(t *testing.T, r capytest.Runner) {
|
||||
execShouldNoError(t, r, "alr", "--interactive=false", "remove", "ca-certificates")
|
||||
execShouldNoError(t, r, "sudo", "alr", "--interactive=false", "remove", "openssl")
|
||||
execShouldNoError(t, r, "alr", "fix")
|
||||
|
@ -21,15 +21,15 @@ package e2etests_test
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/efficientgo/e2e"
|
||||
"go.alt-gnome.ru/capytest"
|
||||
)
|
||||
|
||||
func TestE2EIssue41AutoreqSkiplist(t *testing.T) {
|
||||
dockerMultipleRun(
|
||||
runMatrixSuite(
|
||||
t,
|
||||
"issue-41-autoreq-skiplist",
|
||||
AUTOREQ_AUTOPROV_SYSTEMS,
|
||||
func(t *testing.T, r e2e.Runnable) {
|
||||
func(t *testing.T, r capytest.Runner) {
|
||||
defaultPrepare(t, r)
|
||||
execShouldNoError(t, r, "alr", "build", "-p", "alr-repo/test-autoreq-autoprov")
|
||||
execShouldNoError(t, r, "sh", "-c", "rpm -qp --requires *.rpm | grep \"^/bin/sh$\"")
|
||||
|
@ -21,15 +21,15 @@ package e2etests_test
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/efficientgo/e2e"
|
||||
"go.alt-gnome.ru/capytest"
|
||||
)
|
||||
|
||||
func TestE2EIssue50InstallMultiple(t *testing.T) {
|
||||
dockerMultipleRun(
|
||||
runMatrixSuite(
|
||||
t,
|
||||
"issue-50-install-multiple",
|
||||
COMMON_SYSTEMS,
|
||||
func(t *testing.T, r e2e.Runnable) {
|
||||
func(t *testing.T, r capytest.Runner) {
|
||||
defaultPrepare(t, r)
|
||||
execShouldNoError(t, r, "sudo", "alr", "in", "foo-pkg", "bar-pkg")
|
||||
execShouldNoError(t, r, "cat", "/opt/foo")
|
||||
|
@ -21,15 +21,15 @@ package e2etests_test
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/efficientgo/e2e"
|
||||
"go.alt-gnome.ru/capytest"
|
||||
)
|
||||
|
||||
func TestE2EIssue53LcAllCInfo(t *testing.T) {
|
||||
dockerMultipleRun(
|
||||
runMatrixSuite(
|
||||
t,
|
||||
"issue-53-lc-all-c-info",
|
||||
COMMON_SYSTEMS,
|
||||
func(t *testing.T, r e2e.Runnable) {
|
||||
func(t *testing.T, r capytest.Runner) {
|
||||
defaultPrepare(t, r)
|
||||
execShouldNoError(t, r, "bash", "-c", "LANG=C alr info foo-pkg")
|
||||
},
|
||||
|
@ -21,15 +21,15 @@ package e2etests_test
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/efficientgo/e2e"
|
||||
"go.alt-gnome.ru/capytest"
|
||||
)
|
||||
|
||||
func TestE2EIssue59RmCompletion(t *testing.T) {
|
||||
dockerMultipleRun(
|
||||
runMatrixSuite(
|
||||
t,
|
||||
"issue-59-rm-completion",
|
||||
COMMON_SYSTEMS,
|
||||
func(t *testing.T, r e2e.Runnable) {
|
||||
func(t *testing.T, r capytest.Runner) {
|
||||
defaultPrepare(t, r)
|
||||
execShouldNoError(t, r, "sudo", "alr", "in", "foo-pkg", "bar-pkg")
|
||||
execShouldNoError(t, r, "sh", "-c", "alr rm --generate-bash-completion | grep ^foo-pkg$")
|
||||
|
@ -21,15 +21,15 @@ package e2etests_test
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/efficientgo/e2e"
|
||||
"go.alt-gnome.ru/capytest"
|
||||
)
|
||||
|
||||
func TestE2EIssue72InstallWithDeps(t *testing.T) {
|
||||
dockerMultipleRun(
|
||||
runMatrixSuite(
|
||||
t,
|
||||
"issue-72-install-with-deps",
|
||||
COMMON_SYSTEMS,
|
||||
func(t *testing.T, r e2e.Runnable) {
|
||||
func(t *testing.T, r capytest.Runner) {
|
||||
defaultPrepare(t, r)
|
||||
execShouldNoError(t, r, "sudo", "alr", "in", "test-app-with-lib")
|
||||
},
|
||||
|
@ -21,15 +21,15 @@ package e2etests_test
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/efficientgo/e2e"
|
||||
"go.alt-gnome.ru/capytest"
|
||||
)
|
||||
|
||||
func TestE2EIssue74Upgradable(t *testing.T) {
|
||||
dockerMultipleRun(
|
||||
runMatrixSuite(
|
||||
t,
|
||||
"issue-74-upgradable",
|
||||
COMMON_SYSTEMS,
|
||||
func(t *testing.T, r e2e.Runnable) {
|
||||
func(t *testing.T, r capytest.Runner) {
|
||||
defaultPrepare(t, r)
|
||||
execShouldNoError(t, r, "sudo", "alr", "repo", "set-ref", "alr-repo", "bd26236cd7")
|
||||
execShouldNoError(t, r, "alr", "ref")
|
||||
|
@ -21,15 +21,15 @@ package e2etests_test
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/efficientgo/e2e"
|
||||
"go.alt-gnome.ru/capytest"
|
||||
)
|
||||
|
||||
func TestE2EIssue75InstallWithDeps(t *testing.T) {
|
||||
dockerMultipleRun(
|
||||
runMatrixSuite(
|
||||
t,
|
||||
"issue-75-ref-specify",
|
||||
COMMON_SYSTEMS,
|
||||
func(t *testing.T, r e2e.Runnable) {
|
||||
func(t *testing.T, r capytest.Runner) {
|
||||
defaultPrepare(t, r)
|
||||
execShouldNoError(t, r, "sudo", "alr", "repo", "set-ref", "alr-repo", "bd26236cd7")
|
||||
execShouldNoError(t, r, "sh", "-c", "test $(alr list | wc -l) -eq 2 || exit 1")
|
||||
|
@ -21,15 +21,15 @@ package e2etests_test
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/efficientgo/e2e"
|
||||
"go.alt-gnome.ru/capytest"
|
||||
)
|
||||
|
||||
func Test75SinglePackageRepo(t *testing.T) {
|
||||
dockerMultipleRun(
|
||||
runMatrixSuite(
|
||||
t,
|
||||
"issue-76-single-package-repo",
|
||||
COMMON_SYSTEMS,
|
||||
func(t *testing.T, r e2e.Runnable) {
|
||||
func(t *testing.T, r capytest.Runner) {
|
||||
execShouldNoError(t, r,
|
||||
"sudo",
|
||||
"alr",
|
||||
@ -38,8 +38,9 @@ func Test75SinglePackageRepo(t *testing.T) {
|
||||
REPO_NAME_FOR_E2E_TESTS,
|
||||
"https://gitea.plemya-x.ru/Maks1mS/test-single-package-alr-repo.git",
|
||||
)
|
||||
execShouldNoError(t, r, "sudo", "alr", "ref")
|
||||
execShouldNoError(t, r, "sudo", "alr", "repo", "set-ref", REPO_NAME_FOR_E2E_TESTS, "1075c918be")
|
||||
execShouldNoError(t, r, "alr", "ref")
|
||||
execShouldNoError(t, r, "alr", "fix")
|
||||
execShouldNoError(t, r, "sudo", "alr", "in", "test-single-repo")
|
||||
execShouldNoError(t, r, "sh", "-c", "alr list -U")
|
||||
execShouldNoError(t, r, "sh", "-c", "test $(alr list -U | wc -l) -eq 0 || exit 1")
|
||||
|
@ -21,33 +21,29 @@ package e2etests_test
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/efficientgo/e2e"
|
||||
"go.alt-gnome.ru/capytest"
|
||||
)
|
||||
|
||||
func TestE2EIssue78Mirrors(t *testing.T) {
|
||||
dockerMultipleRun(
|
||||
t,
|
||||
"issue-78-mirrors",
|
||||
COMMON_SYSTEMS,
|
||||
func(t *testing.T, r e2e.Runnable) {
|
||||
defaultPrepare(t, r)
|
||||
execShouldNoError(t, r, "sudo", "alr", "repo", "mirror", "add", REPO_NAME_FOR_E2E_TESTS, "https://gitea.plemya-x.ru/Maks1mS/repo-for-tests.git")
|
||||
execShouldNoError(t, r, "sudo", "alr", "repo", "set-url", REPO_NAME_FOR_E2E_TESTS, "https://example.com")
|
||||
execShouldNoError(t, r, "sudo", "alr", "ref")
|
||||
execShouldNoError(t, r, "sudo", "alr", "repo", "mirror", "clear", REPO_NAME_FOR_E2E_TESTS)
|
||||
execShouldError(t, r, "sudo", "alr", "ref")
|
||||
runMatrixSuite(t, "issue-78-mirrors", COMMON_SYSTEMS, func(t *testing.T, r capytest.Runner) {
|
||||
defaultPrepare(t, r)
|
||||
execShouldNoError(t, r, "sudo", "alr", "repo", "mirror", "add", REPO_NAME_FOR_E2E_TESTS, "https://gitea.plemya-x.ru/Maks1mS/repo-for-tests.git")
|
||||
execShouldNoError(t, r, "sudo", "alr", "repo", "set-url", REPO_NAME_FOR_E2E_TESTS, "https://example.com")
|
||||
execShouldNoError(t, r, "sudo", "alr", "ref")
|
||||
execShouldNoError(t, r, "sudo", "alr", "repo", "mirror", "clear", REPO_NAME_FOR_E2E_TESTS)
|
||||
execShouldError(t, r, "sudo", "alr", "ref")
|
||||
|
||||
execShouldNoError(t, r, "sudo", "alr", "repo", "mirror", "add", REPO_NAME_FOR_E2E_TESTS, "https://gitea.plemya-x.ru/Maks1mS/repo-for-tests.git")
|
||||
execShouldNoError(t, r, "sudo", "alr", "repo", "mirror", "rm", "--partial", REPO_NAME_FOR_E2E_TESTS, "gitea.plemya-x.ru/Maks1mS")
|
||||
execShouldError(t, r, "sudo", "alr", "ref")
|
||||
execShouldNoError(t, r, "sudo", "alr", "repo", "mirror", "add", REPO_NAME_FOR_E2E_TESTS, "https://gitea.plemya-x.ru/Maks1mS/repo-for-tests.git")
|
||||
execShouldNoError(t, r, "sudo", "alr", "repo", "mirror", "rm", "--partial", REPO_NAME_FOR_E2E_TESTS, "gitea.plemya-x.ru/Maks1mS")
|
||||
execShouldError(t, r, "sudo", "alr", "ref")
|
||||
|
||||
execShouldNoError(t, r, "sudo", "alr", "repo", "mirror", "add", REPO_NAME_FOR_E2E_TESTS, "https://gitea.plemya-x.ru/Maks1mS/repo-for-tests.git")
|
||||
execShouldNoError(t, r, "sudo", "alr", "repo", "mirror", "rm", REPO_NAME_FOR_E2E_TESTS, "https://gitea.plemya-x.ru/Maks1mS/repo-for-tests.git")
|
||||
execShouldError(t, r, "sudo", "alr", "ref")
|
||||
execShouldNoError(t, r, "sudo", "alr", "repo", "mirror", "add", REPO_NAME_FOR_E2E_TESTS, "https://gitea.plemya-x.ru/Maks1mS/repo-for-tests.git")
|
||||
execShouldNoError(t, r, "sudo", "alr", "repo", "mirror", "rm", REPO_NAME_FOR_E2E_TESTS, "https://gitea.plemya-x.ru/Maks1mS/repo-for-tests.git")
|
||||
execShouldError(t, r, "sudo", "alr", "ref")
|
||||
|
||||
execShouldNoError(t, r, "sudo", "alr", "repo", "mirror", "add", REPO_NAME_FOR_E2E_TESTS, "https://gitea.plemya-x.ru/Maks1mS/repo-for-tests.git")
|
||||
execShouldNoError(t, r, "sudo", "alr", "repo", "mirror", "rm", REPO_NAME_FOR_E2E_TESTS, "https://gitea.plemya-x.ru/Maks1mS/repo-for-tests.git")
|
||||
execShouldError(t, r, "sudo", "alr", "ref")
|
||||
},
|
||||
execShouldNoError(t, r, "sudo", "alr", "repo", "mirror", "add", REPO_NAME_FOR_E2E_TESTS, "https://gitea.plemya-x.ru/Maks1mS/repo-for-tests.git")
|
||||
execShouldNoError(t, r, "sudo", "alr", "repo", "mirror", "rm", REPO_NAME_FOR_E2E_TESTS, "https://gitea.plemya-x.ru/Maks1mS/repo-for-tests.git")
|
||||
execShouldError(t, r, "sudo", "alr", "ref")
|
||||
},
|
||||
)
|
||||
}
|
||||
|
@ -21,15 +21,15 @@ package e2etests_test
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/efficientgo/e2e"
|
||||
"go.alt-gnome.ru/capytest"
|
||||
)
|
||||
|
||||
func TestE2EIssue81MultiplePackages(t *testing.T) {
|
||||
dockerMultipleRun(
|
||||
runMatrixSuite(
|
||||
t,
|
||||
"issue-81-multiple-packages",
|
||||
COMMON_SYSTEMS,
|
||||
func(t *testing.T, r e2e.Runnable) {
|
||||
func(t *testing.T, r capytest.Runner) {
|
||||
defaultPrepare(t, r)
|
||||
execShouldNoError(t, r, "sudo", "alr", "in", "first-package-with-dashes")
|
||||
execShouldNoError(t, r, "cat", "/opt/first-package")
|
||||
|
@ -21,15 +21,15 @@ package e2etests_test
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/efficientgo/e2e"
|
||||
"go.alt-gnome.ru/capytest"
|
||||
)
|
||||
|
||||
func TestE2EIssue91MultiplePackages(t *testing.T) {
|
||||
dockerMultipleRun(
|
||||
runMatrixSuite(
|
||||
t,
|
||||
"issue-91-set-repo-ref",
|
||||
COMMON_SYSTEMS,
|
||||
func(t *testing.T, r e2e.Runnable) {
|
||||
func(t *testing.T, r capytest.Runner) {
|
||||
defaultPrepare(t, r)
|
||||
execShouldError(t, r, "sudo", "alr", "repo", "set-ref")
|
||||
execShouldError(t, r, "sudo", "alr", "repo", "set-ref", "alr-repo")
|
||||
|
@ -23,27 +23,26 @@ import (
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/efficientgo/e2e"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"go.alt-gnome.ru/capytest"
|
||||
)
|
||||
|
||||
func TestE2EIssue94TwiceBuild(t *testing.T) {
|
||||
dockerMultipleRun(
|
||||
runMatrixSuite(
|
||||
t,
|
||||
"issue-94-twice-build",
|
||||
COMMON_SYSTEMS,
|
||||
func(t *testing.T, r e2e.Runnable) {
|
||||
func(t *testing.T, r capytest.Runner) {
|
||||
defaultPrepare(t, r)
|
||||
|
||||
var stderr bytes.Buffer
|
||||
err := r.Exec(
|
||||
e2e.NewCommand("sudo", "alr", "in", "test-94-app"),
|
||||
e2e.WithExecOptionStderr(&stderr),
|
||||
)
|
||||
assert.NoError(t, err, "command failed")
|
||||
|
||||
output := stderr.String()
|
||||
assert.Equal(t, 1, strings.Count(output, "Building package name=test-94-dep"))
|
||||
r.Command("sudo", "alr", "in", "test-94-app").
|
||||
WithCaptureStderr(&stderr).
|
||||
ExpectSuccess().
|
||||
Run(t)
|
||||
|
||||
assert.Equal(t, 1, strings.Count(stderr.String(), "Building package name=test-94-dep"))
|
||||
},
|
||||
)
|
||||
}
|
||||
|
@ -21,15 +21,15 @@ package e2etests_test
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/efficientgo/e2e"
|
||||
"go.alt-gnome.ru/capytest"
|
||||
)
|
||||
|
||||
func TestE2EIssue95ConfigCommand(t *testing.T) {
|
||||
dockerMultipleRun(
|
||||
runMatrixSuite(
|
||||
t,
|
||||
"issue-95-config-command",
|
||||
COMMON_SYSTEMS,
|
||||
func(t *testing.T, r e2e.Runnable) {
|
||||
func(t *testing.T, r capytest.Runner) {
|
||||
defaultPrepare(t, r)
|
||||
execShouldNoError(t, r, "sh", "-c", "alr config show | grep \"autoPull: true\"")
|
||||
execShouldNoError(t, r, "sh", "-c", "alr config get | grep \"autoPull: true\"")
|
||||
|
@ -20,25 +20,16 @@ package e2etests_test
|
||||
|
||||
import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/efficientgo/e2e"
|
||||
|
||||
expect "github.com/tailscale/goexpect"
|
||||
"go.alt-gnome.ru/capytest"
|
||||
)
|
||||
|
||||
func TestE2EAlrVersion(t *testing.T) {
|
||||
dockerMultipleRun(
|
||||
t,
|
||||
"check-version",
|
||||
COMMON_SYSTEMS,
|
||||
func(t *testing.T, r e2e.Runnable) {
|
||||
runTestCommands(t, r, time.Second*10, []expect.Batcher{
|
||||
&expect.BSnd{S: "alr version\n"},
|
||||
&expect.BExp{R: `^v\d+\.\d+\.\d+(?:-\d+-g[a-f0-9]+)?\n$`},
|
||||
&expect.BSnd{S: "echo $?\n"},
|
||||
&expect.BExp{R: `^0\n$`},
|
||||
})
|
||||
},
|
||||
)
|
||||
runMatrixSuite(t, "version", COMMON_SYSTEMS, func(t *testing.T, r capytest.Runner) {
|
||||
r.Command("alr", "version").
|
||||
ExpectStderrRegex(`^v\d+\.\d+\.\d+(?:-\d+-g[a-f0-9]+)?\n$`).
|
||||
ExpectStdoutEmpty().
|
||||
ExpectSuccess().
|
||||
Run(t)
|
||||
})
|
||||
}
|
||||
|
Reference in New Issue
Block a user