mirror of
https://github.com/tiennm99/ghstats.git
synced 2026-09-02 10:19:54 +00:00
feat: implement profile summary cards with GraphQL fetch and Action wrapper
- Add GraphQL client fetching profile, stats, language aggregation, and per-repo commit histograms for the productive-time heatmap. - Render real SVG cards (profile details, top languages, stats grid, weekday×hour heatmap) with XML escaping and thousands-formatted numbers. - Expand theme palette to 30 built-ins ported from github-readme-stats; add -list-themes, multi-theme rendering, and 'all' shortcut. - Package as Docker-based GitHub Action (action.yml, Dockerfile, entrypoint.sh) with optional auto-commit of generated cards. - Release workflow publishes GHCR image and cross-platform binaries on v* tags. - Unit tests cover rendering, XML escape, number formatting, language sort.
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
package github
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestSortLanguages(t *testing.T) {
|
||||
bytes := map[string]int64{
|
||||
"Go": 500,
|
||||
"Python": 300,
|
||||
"TypeScript": 500, // tie with Go → alphabetical wins
|
||||
"HTML": 100,
|
||||
}
|
||||
colors := map[string]string{
|
||||
"Go": "#00ADD8",
|
||||
"Python": "#3572A5",
|
||||
"TypeScript": "#3178c6",
|
||||
}
|
||||
got := sortLanguages(bytes, colors)
|
||||
|
||||
wantOrder := []string{"Go", "TypeScript", "Python", "HTML"}
|
||||
if len(got) != len(wantOrder) {
|
||||
t.Fatalf("len=%d want %d", len(got), len(wantOrder))
|
||||
}
|
||||
for i, name := range wantOrder {
|
||||
if got[i].Name != name {
|
||||
t.Errorf("pos %d: %q want %q", i, got[i].Name, name)
|
||||
}
|
||||
}
|
||||
if got[0].Color != "#00ADD8" {
|
||||
t.Errorf("Go color=%q want #00ADD8", got[0].Color)
|
||||
}
|
||||
if got[3].Color != "" {
|
||||
t.Errorf("HTML color=%q want empty (missing from colors)", got[3].Color)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user