MCPcopy Create free account
hub / github.com/Facets-cloud/flow / TestRenderCardHTMLAutomationBand

Function TestRenderCardHTMLAutomationBand

internal/app/card_test.go:52–99  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

50}
51
52func TestRenderCardHTMLAutomationBand(t *testing.T) {
53 base := stats.Stats{
54 Window: "all-time",
55 LookupsByKind: map[stats.LookupKind]int{},
56 Savings: stats.Savings{},
57 }
58
59 t.Run("absent when zero", func(t *testing.T) {
60 s := base
61 s.AutoRuns = 0
62 s.OwnerTicks = 0
63 s.PlaybookRuns = 0
64 var buf bytes.Buffer
65 if err := renderCardHTML(&buf, s); err != nil {
66 t.Fatal(err)
67 }
68 html := buf.String()
69 if strings.Contains(html, "runs flow did unattended") {
70 t.Errorf("automation band should be absent when ShowAutomation=false\n---\n%s", html)
71 }
72 if strings.Contains(html, "$") {
73 t.Errorf("no $ expected when ShowAutomation=false\n---\n%s", html)
74 }
75 })
76
77 t.Run("present when nonzero", func(t *testing.T) {
78 s := base
79 s.AutoRuns = 3
80 s.OwnerTicks = 2
81 s.PlaybookRuns = 1
82 s.Savings.AutomationHours = 2.5
83 s.DollarPerHour = 100
84 var buf bytes.Buffer
85 if err := renderCardHTML(&buf, s); err != nil {
86 t.Fatal(err)
87 }
88 html := buf.String()
89 if !strings.Contains(html, "runs flow did unattended") {
90 t.Errorf("automation band should be present when ShowAutomation=true\n---\n%s", html)
91 }
92 if !strings.Contains(html, "6 runs") {
93 t.Errorf("automation band should show total run count (6)\n---\n%s", html)
94 }
95 if !strings.Contains(html, "$") {
96 t.Errorf("automation band should contain $ when ShowAutomation=true\n---\n%s", html)
97 }
98 })
99}
100
101func TestWriteCard(t *testing.T) {
102 dir := t.TempDir()

Callers

nothing calls this directly

Calls 2

renderCardHTMLFunction · 0.85
StringMethod · 0.80

Tested by

no test coverage detected