feat(setup): build start and verify ThothII
This commit is contained in:
@@ -3,11 +3,14 @@ package compose
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"io"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/aritmolab/thothii/tools/tht/internal/config"
|
||||
)
|
||||
|
||||
func TestRunnerPassesEachArgumentWithoutShellSplitting(t *testing.T) {
|
||||
@@ -56,6 +59,39 @@ func TestRunnerReportsMissingDocker(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestInstallationRunnerAppliesComposeArgumentsWithoutRewritingHostDockerCommands(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
recorded := &recordingRunner{}
|
||||
installation := config.Installation{
|
||||
Path: "/tmp/thothii/deploy/local/thothii-installation.yaml",
|
||||
Profile: "local",
|
||||
ProjectDirectory: "/tmp/thothii",
|
||||
EnvFile: "/tmp/thothii/deploy/local/operator.env",
|
||||
}
|
||||
runner := InstallationRunner{Installation: installation, Runner: recorded}
|
||||
if _, err := runner.Run(context.Background(), []string{"compose", "ps"}, nil); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if _, err := runner.Run(context.Background(), []string{"inspect", "core-id"}, nil); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
if got, want := strings.Join(recorded.calls[0], " "), strings.Join(installation.ComposeArgs("ps"), " "); got != want {
|
||||
t.Fatalf("Compose call = %q, want %q", got, want)
|
||||
}
|
||||
if got, want := strings.Join(recorded.calls[1], " "), "inspect core-id"; got != want {
|
||||
t.Fatalf("host Docker call = %q, want %q", got, want)
|
||||
}
|
||||
}
|
||||
|
||||
type recordingRunner struct{ calls [][]string }
|
||||
|
||||
func (r *recordingRunner) Run(_ context.Context, args []string, _ io.Reader) (Result, error) {
|
||||
r.calls = append(r.calls, append([]string(nil), args...))
|
||||
return Result{}, nil
|
||||
}
|
||||
|
||||
func writeExecutable(t *testing.T, contents string) string {
|
||||
t.Helper()
|
||||
path := filepath.Join(t.TempDir(), "fake-docker")
|
||||
|
||||
Reference in New Issue
Block a user