release / go (push) Successful in 1m54s
release / web (push) Failing after 5s
release / integration (push) Failing after 3m44s
release / govulncheck (push) Successful in 20s
release / Attach APK to the Release (tag releases only) (push) Canceled after 0s
release / Build + push container image (push) Canceled after 0s
release / Verify release artifacts (tag releases only) (push) Canceled after 0s
release / Build signed APK (push) Canceled after 19s
release / android (push) Canceled after 2m37s
Minstrel is now a viewer of the library it is pointed at. Finding, downloading and filing music moves out of it. Removed from the server: - the request flow (requests, approval, auto-approve) and the wanted list, follows, release profiles and release blocks; - searching indexers, the download clients, the importer, the album lifecycle and missing-file re-acquisition; - the catalogue's discography, search and art (the MusicBrainz release and track-list cache stays, for the duplicate resolver); - Discover: its suggestions of artists not in the library, snoozes, the candidate-artist tag enrichment and its tuning scope; - writes to acquisition tables from moving the library folder and from merging duplicates, the want-list join on Suspect sources, the sealing of acquisition credentials, and the release-group lookup only re-acquisition used. Settling a wrong-slot duplicate no longer sets the release aside: the copies go and their slots show as missing until a good copy is in the library. Removed from the web: Admin > Acquisition and Requests, /requests, /discover, Follow on the artist page, the auto-approve toggle, and the Collection's wanted-list tabs. The Collection is now the library's health: an overview, Reports, Duplicates, Suspect sources and Missing files. The README and docs no longer describe getting music. The tables stay for now; a later migration drops them. The request notification kinds and the Android screens are still to go. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
91 lines
2.9 KiB
Go
91 lines
2.9 KiB
Go
package api
|
|
|
|
import (
|
|
"context"
|
|
"encoding/json"
|
|
"net/http"
|
|
"net/http/httptest"
|
|
"testing"
|
|
|
|
"github.com/go-chi/chi/v5"
|
|
|
|
"git.fabledsword.com/bvandeusen/minstrel/internal/auth"
|
|
"git.fabledsword.com/bvandeusen/minstrel/internal/db/dbq"
|
|
)
|
|
|
|
func getAdminSummary(t *testing.T, h *handlers, user dbq.User) (int, adminSummaryView) {
|
|
t.Helper()
|
|
r := chi.NewRouter()
|
|
r.Route("/api/admin", func(admin chi.Router) {
|
|
admin.Use(auth.RequireAdmin())
|
|
admin.Get("/summary", h.handleGetAdminSummary)
|
|
})
|
|
w := httptest.NewRecorder()
|
|
r.ServeHTTP(w, withUser(httptest.NewRequest(http.MethodGet, "/api/admin/summary", nil), user))
|
|
var out adminSummaryView
|
|
if w.Code == http.StatusOK {
|
|
if err := json.Unmarshal(w.Body.Bytes(), &out); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
}
|
|
return w.Code, out
|
|
}
|
|
|
|
// The summary counts each queue an admin acts on and says since when the
|
|
// oldest item has waited; an empty queue has no since.
|
|
func TestAdminSummary_CountsTheQueuesAndSinceWhen(t *testing.T) {
|
|
h, _ := testHandlers(t)
|
|
truncateLibrary(t, h.pool)
|
|
admin := seedUser(t, h.pool, "admin", "pw", true)
|
|
listener := seedUser(t, h.pool, "listener", "pw", false)
|
|
ctx := context.Background()
|
|
|
|
code, empty := getAdminSummary(t, h, admin)
|
|
if code != http.StatusOK {
|
|
t.Fatalf("status = %d", code)
|
|
}
|
|
if empty.Missing.Count != 0 || empty.Missing.Since != nil {
|
|
t.Errorf("empty summary = %+v", empty)
|
|
}
|
|
|
|
track := seedQuarantineTrack(t, h, "sum-missing")
|
|
if _, err := h.pool.Exec(ctx, `UPDATE tracks SET missing_since = now() WHERE id = $1`, track.ID); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
_, got := getAdminSummary(t, h, admin)
|
|
if got.Missing.Count != 1 || got.Missing.Since == nil {
|
|
t.Errorf("missing = %+v, want 1 with a since", got.Missing)
|
|
}
|
|
|
|
if code, _ := getAdminSummary(t, h, listener); code != http.StatusForbidden {
|
|
t.Errorf("a listener got %d, want 403", code)
|
|
}
|
|
}
|
|
|
|
// Duplicates count what needs review: a cross-release group is kept and
|
|
// linked by the resolver and waits on nobody.
|
|
func TestAdminSummary_DuplicatesCountOnlyWhatNeedsReview(t *testing.T) {
|
|
h, _ := testHandlers(t)
|
|
truncateLibrary(t, h.pool)
|
|
admin := seedUser(t, h.pool, "dupsum-admin", "pw", true)
|
|
ctx := context.Background()
|
|
a := seedQuarantineTrack(t, h, "dupsum-a")
|
|
b := seedQuarantineTrack(t, h, "dupsum-b")
|
|
for _, g := range []struct{ key, class string }{{"dupsum-review", "review"}, {"dupsum-cross", "cross_release"}} {
|
|
var id [16]byte
|
|
if err := h.pool.QueryRow(ctx,
|
|
`INSERT INTO duplicate_groups (member_key, tier, class) VALUES ($1, 'acoustic', $2) RETURNING id`,
|
|
g.key, g.class).Scan(&id); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if _, err := h.pool.Exec(ctx, `INSERT INTO duplicate_group_members (group_id, track_id) VALUES ($1, $2), ($1, $3)`,
|
|
id, a.ID, b.ID); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
}
|
|
_, got := getAdminSummary(t, h, admin)
|
|
if got.Duplicates.Count != 1 {
|
|
t.Errorf("duplicates = %d, want 1: the cross-release group needs nobody", got.Duplicates.Count)
|
|
}
|
|
}
|