refactor: migrate lint config to v2, remove daemon auto-upgrade, add trust badges
This commit is contained in:
parent
a13104bdb7
commit
efa4562acd
18 changed files with 188 additions and 268 deletions
|
|
@ -324,62 +324,3 @@ func TestHeartbeatWithoutUpgradeSignal(t *testing.T) {
|
|||
t.Errorf("expected no upgrade signal, got %+v", resp.Upgrade)
|
||||
}
|
||||
}
|
||||
|
||||
func TestReportUpgradeResult(t *testing.T) {
|
||||
var received UpgradeResult
|
||||
srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
if r.URL.Path != "/api/internal/agent/upgrade-result" {
|
||||
t.Errorf("path = %s, want /api/internal/agent/upgrade-result", r.URL.Path)
|
||||
}
|
||||
if r.Method != http.MethodPost {
|
||||
t.Errorf("method = %s, want POST", r.Method)
|
||||
}
|
||||
json.NewDecoder(r.Body).Decode(&received)
|
||||
json.NewEncoder(w).Encode(struct{ Success bool }{Success: true})
|
||||
}))
|
||||
defer srv.Close()
|
||||
|
||||
c := NewClient(srv.URL, "test-key", "unarr-test")
|
||||
err := c.ReportUpgradeResult(context.Background(), UpgradeResult{
|
||||
AgentID: "agent-1",
|
||||
Success: true,
|
||||
Version: "2.0.0",
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatalf("ReportUpgradeResult failed: %v", err)
|
||||
}
|
||||
if received.AgentID != "agent-1" {
|
||||
t.Errorf("agentId = %q, want agent-1", received.AgentID)
|
||||
}
|
||||
if !received.Success {
|
||||
t.Error("expected success=true")
|
||||
}
|
||||
if received.Version != "2.0.0" {
|
||||
t.Errorf("version = %q, want 2.0.0", received.Version)
|
||||
}
|
||||
}
|
||||
|
||||
func TestReportUpgradeResultFailure(t *testing.T) {
|
||||
var received UpgradeResult
|
||||
srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
json.NewDecoder(r.Body).Decode(&received)
|
||||
json.NewEncoder(w).Encode(struct{ Success bool }{Success: true})
|
||||
}))
|
||||
defer srv.Close()
|
||||
|
||||
c := NewClient(srv.URL, "test-key", "unarr-test")
|
||||
err := c.ReportUpgradeResult(context.Background(), UpgradeResult{
|
||||
AgentID: "agent-1",
|
||||
Success: false,
|
||||
Error: "checksum mismatch",
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatalf("ReportUpgradeResult failed: %v", err)
|
||||
}
|
||||
if received.Success {
|
||||
t.Error("expected success=false")
|
||||
}
|
||||
if received.Error != "checksum mismatch" {
|
||||
t.Errorf("error = %q, want 'checksum mismatch'", received.Error)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue