test: make quality gate deterministic under host sudo installs

This commit is contained in:
Brad Stein 2026-04-09 04:28:58 -03:00
parent 1cdb2cb3f3
commit a493670dbd
3 changed files with 17 additions and 0 deletions

View File

@ -75,6 +75,15 @@ func TestMaxIntAndStartupShutdownCooldown(t *testing.T) {
// Signature: TestBuildSSHBaseArgsNoJumpHasStableOrdering(t *testing.T). // Signature: TestBuildSSHBaseArgsNoJumpHasStableOrdering(t *testing.T).
// Why: keeps behavior explicit so startup/shutdown workflows remain maintainable as services evolve. // Why: keeps behavior explicit so startup/shutdown workflows remain maintainable as services evolve.
func TestBuildSSHBaseArgsNoJumpHasStableOrdering(t *testing.T) { func TestBuildSSHBaseArgsNoJumpHasStableOrdering(t *testing.T) {
origConfigCandidates := append([]string(nil), sshConfigCandidates...)
origIdentityCandidates := append([]string(nil), sshIdentityCandidates...)
sshConfigCandidates = []string{"/path/that/does/not/exist/ssh_config"}
sshIdentityCandidates = []string{"/path/that/does/not/exist/id_ed25519"}
t.Cleanup(func() {
sshConfigCandidates = origConfigCandidates
sshIdentityCandidates = origIdentityCandidates
})
cfg := config.Config{SSHPort: 10022} cfg := config.Config{SSHPort: 10022}
args := buildSSHBaseArgs(cfg) args := buildSSHBaseArgs(cfg)
want := []string{ want := []string{

View File

@ -117,6 +117,10 @@ func TestWriteIntentFailsWhenParentIsFile(t *testing.T) {
// Signature: TestReadIntentFailsOnPermissionError(t *testing.T). // Signature: TestReadIntentFailsOnPermissionError(t *testing.T).
// Why: covers read error branch distinct from not-exist and empty-file handling. // Why: covers read error branch distinct from not-exist and empty-file handling.
func TestReadIntentFailsOnPermissionError(t *testing.T) { func TestReadIntentFailsOnPermissionError(t *testing.T) {
if os.Geteuid() == 0 {
t.Skip("permission semantics differ under root")
}
path := filepath.Join(t.TempDir(), "intent.json") path := filepath.Join(t.TempDir(), "intent.json")
if err := os.WriteFile(path, []byte(`{"state":"normal"}`), 0o640); err != nil { if err := os.WriteFile(path, []byte(`{"state":"normal"}`), 0o640); err != nil {
t.Fatalf("write intent file: %v", err) t.Fatalf("write intent file: %v", err)

View File

@ -67,6 +67,10 @@ func TestStoreLoadHandlesEmptyFile(t *testing.T) {
// Signature: TestStoreLoadReturnsErrorOnUnhealableDecode(t *testing.T). // Signature: TestStoreLoadReturnsErrorOnUnhealableDecode(t *testing.T).
// Why: covers decode failure path where replacement write itself can fail. // Why: covers decode failure path where replacement write itself can fail.
func TestStoreLoadReturnsErrorOnUnhealableDecode(t *testing.T) { func TestStoreLoadReturnsErrorOnUnhealableDecode(t *testing.T) {
if os.Geteuid() == 0 {
t.Skip("permission semantics differ under root")
}
dir := t.TempDir() dir := t.TempDir()
path := filepath.Join(dir, "runs.json") path := filepath.Join(dir, "runs.json")
if err := os.WriteFile(path, []byte("{bad-json"), 0o640); err != nil { if err := os.WriteFile(path, []byte("{bad-json"), 0o640); err != nil {