mesh/merge-gate pass: builds mesh-host → ace, g14, novox, shanks; no bus step; every machine composes with the change as it did without (4 of 4 compose)
mesh/repo-check pass: its merge-check.sh passed
mesh/delivery-group group fix/233-a-failed-probe-fails-only-what-needs-the-tool-2 ready: every member ready, and composed together they pass
mesh/delivery superseded: a newer head of the same pull request
59 lines
2.2 KiB
Go
59 lines
2.2 KiB
Go
package main
|
|
|
|
import (
|
|
"context"
|
|
"os"
|
|
"path/filepath"
|
|
"strings"
|
|
"testing"
|
|
|
|
"github.com/novox/mesh-host/internal/declaration"
|
|
"github.com/novox/mesh-host/internal/system"
|
|
)
|
|
|
|
// Defends novox/hq issue 233: a package manager that does not answer is said even when nothing declared
|
|
// needs it — the apply is partial, never "applied" — and the report names it under one key, so the mesh
|
|
// counts it as one failure that goes on.
|
|
func TestAPackageManagerThatDoesNotAnswerIsSaidWithNoPackageDeclared(t *testing.T) {
|
|
unansweringPacman(t)
|
|
dir := t.TempDir()
|
|
opts := options{state: filepath.Join(dir, "state.json"), out: &strings.Builder{}}
|
|
conf := filepath.Join(dir, "pacman.conf")
|
|
raw := []byte(`{"declaration":1,"resources":[{"id":"pacman.conf","type":"file","path":"` + conf +
|
|
`","content":"[options]\n"}]}`)
|
|
d, err := declaration.ParseFileTrusted(raw)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
err = runApply(context.Background(), opts, d, raw, fromFile)
|
|
if err == nil || !strings.Contains(err.Error(), "applied only in part") || !strings.Contains(err.Error(), "could not be read") {
|
|
t.Fatalf("an apply whose package manager did not answer was not said to be partial: %v", err)
|
|
}
|
|
if _, statErr := os.Stat(conf); statErr != nil {
|
|
t.Fatalf("the file was not written: %v", statErr)
|
|
}
|
|
|
|
report := applyAndKeep(context.Background(), opts, raw, nil, nil, nil)
|
|
if report.Refused != "" {
|
|
t.Fatalf("refused whole: %s", report.Refused)
|
|
}
|
|
why, ok := report.Failed["the package manager (pacman)"]
|
|
if !ok || !strings.Contains(why, "could not be read") {
|
|
t.Errorf("the report does not name the package manager with the probe's words: %v", report.Failed)
|
|
}
|
|
}
|
|
|
|
// A system whose probe asks the system itself, not a tool a resource needs, still refuses whole: nothing
|
|
// the mesh declares can remove it, and nothing else stands between that host and the wrong machine.
|
|
func TestASystemWithNoPackageManagerStillRefusesWhole(t *testing.T) {
|
|
t.Setenv("PATH", t.TempDir())
|
|
sys, err := system.For("android")
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
probe, err := probePackageManager(context.Background(), sys)
|
|
if err == nil || probe != nil {
|
|
t.Fatalf("the android host's failed probe did not refuse: %v, %+v", err, probe)
|
|
}
|
|
}
|