feat(setup): build start and verify ThothII
This commit is contained in:
@@ -14,6 +14,7 @@ import (
|
||||
"github.com/aritmolab/thothii/tools/tht/internal/compose"
|
||||
"github.com/aritmolab/thothii/tools/tht/internal/config"
|
||||
"github.com/aritmolab/thothii/tools/tht/internal/pi"
|
||||
"github.com/aritmolab/thothii/tools/tht/internal/setup"
|
||||
"github.com/aritmolab/thothii/tools/tht/internal/testsupport"
|
||||
)
|
||||
|
||||
@@ -25,7 +26,7 @@ func TestInstallationRunnerMapsProfileToSessionInventoryScope(t *testing.T) {
|
||||
{profile: "local", want: "mine"},
|
||||
{profile: "server", want: "all"},
|
||||
} {
|
||||
runner := installationRunner{installation: config.Installation{Profile: test.profile}}
|
||||
runner := compose.InstallationRunner{Installation: config.Installation{Profile: test.profile}}
|
||||
if got := runner.SessionInventoryScope(); got != test.want {
|
||||
t.Fatalf("profile %q maps to session scope %q, want %q", test.profile, got, test.want)
|
||||
}
|
||||
@@ -107,6 +108,50 @@ func TestBootstrapCommandsDoNotRequireAnInstallationDescriptor(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestSetupCommandBuildsAndStartsUnlessConfigureOnlyIsRequested(t *testing.T) {
|
||||
projectRoot := newProjectWithoutInstallation(t)
|
||||
previousDirectory, err := os.Getwd()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := os.Chdir(projectRoot); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
t.Cleanup(func() { _ = os.Chdir(previousDirectory) })
|
||||
|
||||
for _, test := range []struct {
|
||||
name string
|
||||
args []string
|
||||
want bool
|
||||
}{
|
||||
{name: "default", args: []string{"--non-interactive", "--installation-id", "cli", "--profile", "local"}, want: false},
|
||||
{name: "configuration only", args: []string{"--configure-only", "--non-interactive", "--installation-id", "cli", "--profile", "local"}, want: true},
|
||||
} {
|
||||
t.Run(test.name, func(t *testing.T) {
|
||||
var received setup.Request
|
||||
executor := func(_ context.Context, _ compose.Runner, request setup.Request, _ io.Reader, _ io.Writer) (setup.Result, error) {
|
||||
received = request
|
||||
return setup.Result{DescriptorPath: filepath.Join(projectRoot, "deploy", "cli", "thothii-installation.yaml"), Configured: true, Built: !request.ConfigureOnly, Started: !request.ConfigureOnly, Healthy: !request.ConfigureOnly}, nil
|
||||
}
|
||||
var stdout, stderr bytes.Buffer
|
||||
code := setupCommandWith(context.Background(), "", test.args, strings.NewReader(""), compose.NewRunner("docker"), executor, &stdout, &stderr)
|
||||
if code != 0 {
|
||||
t.Fatalf("setupCommandWith() = %d, stderr = %q", code, stderr.String())
|
||||
}
|
||||
if received.ConfigureOnly != test.want {
|
||||
t.Fatalf("ConfigureOnly = %t, want %t", received.ConfigureOnly, test.want)
|
||||
}
|
||||
canonicalRoot, pathErr := filepath.EvalSymlinks(projectRoot)
|
||||
if pathErr != nil {
|
||||
t.Fatal(pathErr)
|
||||
}
|
||||
if received.ProjectRoot != canonicalRoot {
|
||||
t.Fatalf("ProjectRoot = %q, want %q", received.ProjectRoot, canonicalRoot)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// Catches interactive configuration prompts that use retired model-only data instead of the
|
||||
// provider, model, and reasoning choices supplied by the dedicated Pi Management API.
|
||||
func TestResolvePiConfigureUsesNumberedClosedChoicesOnlyForTTY(t *testing.T) {
|
||||
|
||||
Reference in New Issue
Block a user