Files
pipu-music/services/api/internal/library/palette_test.go
T
mrleo1nidandClaude Opus 5.5 8b76aa3964
ci / mobile / mobile (Metro-бандл Android) (push) Successful in 55s
ci / ts / ts (packages + web) (push) Successful in 1m0s
ci / docker / docker (образы собираются — их сервер собирает сам при обновлении) (push) Successful in 34s
ci / api / api (push) Successful in 26s
ci / contract / contract (сгенерированный код совпадает с openapi.yaml) (push) Successful in 34s
feat: album covers with palettes and signed links (M2)
- covers are taken from the embedded picture of the first track or a
  cover/folder/front image in the album folder, converted by ffmpeg to
  WebP 64/300/1200 and named by content hash, so albums sharing a cover
  share the files; a full scan looks again for albums without one
- a 3-colour palette (dominant, second, most saturated accent) from a
  deterministic k-means feeds placeholders, page tints and the wave
- /covers/{id} is public but HMAC-signed and immutable; nginx serves
  the file via X-Accel-Redirect, X_ACCEL=false serves it from api
- the web client picks the size by display size and pixel density
- install.sh and update.sh generate STREAM_SIGNING_KEY

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-20 07:06:15 +03:00

28 lines
696 B
Go

package library
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestPalette(t *testing.T) {
// 60% тёмно-синего, 30% белого, 10% ярко-оранжевого: оранжевый — акцент, хотя его меньше всего.
var px []byte
add := func(n int, r, g, b byte) {
for range n {
px = append(px, r, g, b)
}
}
add(600, 20, 30, 90)
add(300, 250, 250, 250)
add(100, 250, 140, 20)
p := Palette(px)
assert.Equal(t, []string{"#141E5A", "#FAFAFA", "#FA8C14"}, p)
assert.Equal(t, p, Palette(px), "deterministic")
assert.Len(t, Palette([]byte{1, 2, 3}), 3, "single colour fills all three slots")
assert.Nil(t, Palette(nil))
}