feat: T1016 dns_config probe + server-side drift detection + Crucible DNS DRIFT badge

This commit is contained in:
AetherForge
2026-05-30 23:26:50 -07:00
parent 6704933568
commit d005d5d07c
48 changed files with 4621 additions and 22 deletions

View File

@@ -3,6 +3,7 @@ package db
import (
"database/sql"
"errors"
"strings"
"testing"
"time"
@@ -92,6 +93,24 @@ func TestSetPinnedBuild(t *testing.T) {
}
}
func TestSetPinnedBuildUnknownID(t *testing.T) {
d := openTestDB(t)
now := time.Now()
insertBuild(t, d, &models.BuildRecord{ID: "b1", WorkerName: "w", ServerURL: "u", Wallet: "w", CreatedAt: now, Pinned: true})
err := d.SetPinnedBuild("missing")
if err == nil {
t.Fatal("expected error for unknown build id")
}
if !strings.Contains(err.Error(), "not found") {
t.Fatalf("unexpected error: %v", err)
}
b1, _ := d.GetBuild("b1")
if b1.Pinned {
t.Fatal("unknown id should leave builds unpinned, not keep prior pin")
}
}
func TestGetLatestBuildForPlatform(t *testing.T) {
d := openTestDB(t)
base := time.Now().UTC().Truncate(time.Second)

View File

@@ -307,7 +307,8 @@ func (d *Database) GetLatestBuildForPlatform(platform string) (*models.BuildReco
}
// SetPinnedBuild unpins all builds then pins the one with the given id.
// If id is empty, all builds are unpinned.
// If id is empty, all builds are unpinned. Returns an error when id is
// non-empty but no build row matches (avoids leaving all builds unpinned).
func (d *Database) SetPinnedBuild(id string) error {
_, err := d.Exec(`UPDATE builds SET pinned = 0`)
if err != nil {
@@ -316,8 +317,18 @@ func (d *Database) SetPinnedBuild(id string) error {
if id == "" {
return nil
}
_, err = d.Exec(`UPDATE builds SET pinned = 1 WHERE id = ?`, id)
return err
res, err := d.Exec(`UPDATE builds SET pinned = 1 WHERE id = ?`, id)
if err != nil {
return err
}
n, err := res.RowsAffected()
if err != nil {
return err
}
if n == 0 {
return fmt.Errorf("build not found: %s", id)
}
return nil
}
func (d *Database) ListBuilds(limit int) ([]*models.BuildRecord, error) {