generated from mathias/template-go-web
TDD: IssueNodes parses /repos/issues/search into stage nodes (title, repo tag, clickable html_url). gitea.MyIssues() reads GITEA_TOKEN and skips gracefully when unset, mirroring the existing liveOverlay fallback pattern. Single-operator homelab, not per-visitor OAuth: a static read-only PAT gates on "cleared Authentik forward-auth", not per-user token exchange — see #4 discussion. GITEA_TOKEN provisioning in infra (ExternalSecret) is a separate follow-up; without it the overlay is inert (no crash, just no live nodes), so this ships safely ahead of that wiring. Nodes with a url now render as clickable <a class="node"> instead of <div class="node">.
42 lines
1.3 KiB
Go
42 lines
1.3 KiB
Go
package atlas_test
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"git.d-ma.be/mathias/cad-atlas/internal/atlas"
|
|
)
|
|
|
|
func TestIssueNodes_OneNodePerIssueWithRepoTagAndURL(t *testing.T) {
|
|
search := []byte(`[
|
|
{"number":212,"title":"segment-embedder: add smoke test","html_url":"https://git.d-ma.be/mathias/infra/issues/212","repository":{"full_name":"mathias/infra"}},
|
|
{"number":8,"title":"Write cad-atlas's own vargo-gate candidate","html_url":"https://git.d-ma.be/mathias/cad-atlas/issues/8","repository":{"full_name":"mathias/cad-atlas"}}
|
|
]`)
|
|
|
|
nodes, err := atlas.IssueNodes(search)
|
|
if err != nil {
|
|
t.Fatalf("IssueNodes: %v", err)
|
|
}
|
|
if len(nodes) != 2 {
|
|
t.Fatalf("want 2 nodes, got %d", len(nodes))
|
|
}
|
|
if nodes[0].Title != "#212 segment-embedder: add smoke test" {
|
|
t.Fatalf("title = %q", nodes[0].Title)
|
|
}
|
|
if nodes[0].URL != "https://git.d-ma.be/mathias/infra/issues/212" {
|
|
t.Fatalf("url = %q", nodes[0].URL)
|
|
}
|
|
if len(nodes[0].Tags) != 2 || nodes[0].Tags[0] != "live · Gitea" || nodes[0].Tags[1] != "mathias/infra" {
|
|
t.Fatalf("tags = %v", nodes[0].Tags)
|
|
}
|
|
}
|
|
|
|
func TestIssueNodes_EmptyListReturnsEmptyNotNil(t *testing.T) {
|
|
nodes, err := atlas.IssueNodes([]byte(`[]`))
|
|
if err != nil {
|
|
t.Fatalf("IssueNodes: %v", err)
|
|
}
|
|
if nodes == nil || len(nodes) != 0 {
|
|
t.Fatalf("nodes = %+v, want empty non-nil slice", nodes)
|
|
}
|
|
}
|