Initial commit on Forgejo
Some checks failed
CI and releases / Test and vet (push) Failing after 1s
CI and releases / Build release binaries (push) Has been skipped
CI and releases / Publish GitHub release (push) Has been skipped

Fresh repository history for elektrine/tarakan-client hosted at
https://git.elektrine.com/elektrine/tarakan-client.
This commit is contained in:
Maxfield Luke 2026-07-29 04:56:36 -04:00
commit 58b29a7f84
70 changed files with 12994 additions and 0 deletions

View file

@ -0,0 +1,44 @@
package api
import "testing"
func TestContractValueLabel(t *testing.T) {
cases := []struct {
name string
value *ContractValue
want string
}{
{"nil is silent", nil, ""},
{"nothing on offer", &ContractValue{}, ""},
{"cash only", &ContractValue{Cents: 25_000, Count: 1}, "$250"},
{"credits only", &ContractValue{Credits: 500, Count: 1}, "500 credits"},
{"both", &ContractValue{Cents: 10_000, Credits: 50, Count: 2}, "$100 + 50 credits"},
// A contract can exist with no value recorded yet; say nothing rather
// than print a misleading "$0".
{"counted but valueless", &ContractValue{Count: 1}, ""},
}
for _, tc := range cases {
t.Run(tc.name, func(t *testing.T) {
if got := tc.value.Label(); got != tc.want {
t.Fatalf("Label() = %q, want %q", got, tc.want)
}
})
}
}
func TestSuppressionsTotal(t *testing.T) {
var empty Suppressions
if empty.Total() != 0 {
t.Fatalf("empty total = %d", empty.Total())
}
s := Suppressions{
Repository: []Suppression{{Title: "a"}, {Title: "b"}},
Patterns: []Suppression{{Title: "c"}},
}
if s.Total() != 3 {
t.Fatalf("total = %d, want 3", s.Total())
}
}