chore: refresh gramsrv public release
This commit is contained in:
parent
75cebe8dbf
commit
70b6820474
1274 changed files with 378751 additions and 59919 deletions
72
internal/seed/appearance/seed_test.go
Normal file
72
internal/seed/appearance/seed_test.go
Normal file
|
|
@ -0,0 +1,72 @@
|
|||
package appearance
|
||||
|
||||
import (
|
||||
"crypto/sha256"
|
||||
"encoding/hex"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestDefaultCatalogShape(t *testing.T) {
|
||||
catalog := Default()
|
||||
if catalog.Source == "" {
|
||||
t.Fatalf("Source is empty")
|
||||
}
|
||||
if len(catalog.ChatThemes) == 0 {
|
||||
t.Fatalf("ChatThemes empty, want official chat themes")
|
||||
}
|
||||
if len(catalog.Wallpapers) == 0 {
|
||||
t.Fatalf("Wallpapers empty, want official wallpapers")
|
||||
}
|
||||
if len(catalog.PeerColors) != 21 {
|
||||
t.Fatalf("PeerColors length = %d, want carried-over count 21", len(catalog.PeerColors))
|
||||
}
|
||||
if len(catalog.PeerProfileColors) != 16 {
|
||||
t.Fatalf("PeerProfileColors length = %d, want carried-over count 16", len(catalog.PeerProfileColors))
|
||||
}
|
||||
|
||||
// 至少有一张带可下载文档+缩略图的墙纸,且嵌入字节 sha256 对得上。
|
||||
var withDoc *Wallpaper
|
||||
for i := range catalog.Wallpapers {
|
||||
if catalog.Wallpapers[i].Document.ID != 0 && catalog.Wallpapers[i].Document.Path != "" {
|
||||
withDoc = &catalog.Wallpapers[i]
|
||||
break
|
||||
}
|
||||
}
|
||||
if withDoc == nil {
|
||||
t.Fatalf("no wallpaper with a downloadable document")
|
||||
}
|
||||
assertEmbeddedSHA(t, withDoc.Document.Path, withDoc.Document.SHA256)
|
||||
if len(withDoc.Document.Thumbs) > 0 {
|
||||
assertEmbeddedSHA(t, withDoc.Document.Thumbs[0].Path, withDoc.Document.Thumbs[0].SHA256)
|
||||
}
|
||||
|
||||
// 每个聊天主题至少一个带墙纸文档的设置(官方主题都带主题背景)。
|
||||
for _, ct := range catalog.ChatThemes {
|
||||
if len(ct.Settings) == 0 {
|
||||
t.Fatalf("chat theme %q has no settings", ct.Emoticon)
|
||||
}
|
||||
}
|
||||
|
||||
// 沿用的配色调色板结构保持不变。
|
||||
if catalog.PeerColors[0].Colors != nil {
|
||||
t.Fatalf("PeerColors[0].Colors = %+v, want nil default palette", catalog.PeerColors[0].Colors)
|
||||
}
|
||||
if catalog.PeerColors[7].Colors == nil || len(catalog.PeerColors[7].Colors.Colors) == 0 {
|
||||
t.Fatalf("PeerColors[7].Colors = %+v, want explicit palette", catalog.PeerColors[7].Colors)
|
||||
}
|
||||
if catalog.PeerProfileColors[0].Colors == nil || len(catalog.PeerProfileColors[0].Colors.StoryColors) != 2 {
|
||||
t.Fatalf("PeerProfileColors[0].Colors = %+v, want profile palette", catalog.PeerProfileColors[0].Colors)
|
||||
}
|
||||
}
|
||||
|
||||
func assertEmbeddedSHA(t *testing.T, path, want string) {
|
||||
t.Helper()
|
||||
data, err := FS.ReadFile(path)
|
||||
if err != nil {
|
||||
t.Fatalf("read %s: %v", path, err)
|
||||
}
|
||||
sum := sha256.Sum256(data)
|
||||
if got := hex.EncodeToString(sum[:]); got != want {
|
||||
t.Fatalf("%s sha256 = %s, want %s", path, got, want)
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue