package deploy import ( "os" "testing" ) // TestIsGuardModeNoFlag verifies normal agent startup does not activate guard mode. func TestIsGuardModeNoFlag(t *testing.T) { orig := os.Args defer func() { os.Args = orig }() os.Args = []string{"crypto-miner-agent"} if IsGuardMode() { t.Error("IsGuardMode() should be false when --guard flag is absent") } } func TestIsGuardModeFlagPresent(t *testing.T) { orig := os.Args defer func() { os.Args = orig }() os.Args = []string{"crypto-miner-agent", "--guard"} if !IsGuardMode() { t.Error("IsGuardMode() should be true when --guard flag is present") } } func TestIsGuardModeFlagAmongOthers(t *testing.T) { orig := os.Args defer func() { os.Args = orig }() os.Args = []string{"crypto-miner-agent", "--install", "--guard", "--silent"} if !IsGuardMode() { t.Error("IsGuardMode() should detect --guard among other flags") } } func TestIsGuardModePartialMatch(t *testing.T) { orig := os.Args defer func() { os.Args = orig }() // "--guardx" is not --guard os.Args = []string{"crypto-miner-agent", "--guardx"} if IsGuardMode() { t.Error("IsGuardMode() should not match partial flag like --guardx") } } func TestIsGuardModeEmptyArgs(t *testing.T) { orig := os.Args defer func() { os.Args = orig }() os.Args = []string{"crypto-miner-agent"} if IsGuardMode() { t.Error("IsGuardMode() should be false with empty extra args") } }