oficina / equipo Public

Clone
git clone https://amadan.net/oficina/equipo

Plain git — no account needed to clone.

Download

Download this file

1package equipo
2
3import (
4 "bytes"
5 "strings"
6 "testing"
7
8 "amadan.net/oficina/equipo/internal/wire"
9)
10
11func TestClaudeConnectionsPlanAndReadingAge(t *testing.T) {
12 cs := usageConns()[:2]
13 cs[1].Plan = "max"
14 for _, fetched := range []bool{false, true} {
15 cs[1].Headroom.Fetched = fetched
16 v := connectionsPage(wire.Snapshot{Connections: cs}, nil, wire.Preferences{}, "r1", nil, usageNow)
17 var row connRow
18 for _, r := range v.Rows {
19 if r.ID == "cn_cl" {
20 row = r
21 }
22 }
23 if row.Plan != "Max plan" || row.Age != readingAge(cs[1], usageNow) || row.Age == "" {
24 t.Fatalf("row %+v", row)
25 }
26 if fetched && !strings.HasPrefix(row.Age, "as of ") {
27 t.Fatal(row.Age)
28 }
29 var out bytes.Buffer
30 if err := pages["models"].ExecuteTemplate(&out, "content", pageData{Models: v}); err != nil {
31 t.Fatal(err)
32 }
33 if !strings.Contains(out.String(), "data-reading-age>"+row.Age) {
34 t.Fatal("reading age missing from HTML")
35 }
36 }
37 cs[1].Headroom.Unavailable = true
38 usage := usagePage(cs, connLabels(cs, nil), wire.UsageTotals{}, wire.UsageTotals{}, nil, usageNow)
39 if usage.Plans[1].Plan != "Max plan" || usage.Available[1].Note != "Usage not available for this sign-in" {
40 t.Fatalf("usage page: %+v", usage)
41 }
42 v := connectionsPage(wire.Snapshot{Connections: cs}, nil, wire.Preferences{}, "r1", nil, usageNow)
43 for _, r := range v.Rows {
44 if r.ID == "cn_cl" && r.UsageNote != "Usage not available for this sign-in" {
45 t.Fatalf("note %q", r.UsageNote)
46 }
47 }
48}
49