Initial commit on Forgejo
Fresh repository history for elektrine/tarakan-client hosted at https://git.elektrine.com/elektrine/tarakan-client.
This commit is contained in:
commit
58b29a7f84
70 changed files with 12994 additions and 0 deletions
44
internal/api/contract_value_test.go
Normal file
44
internal/api/contract_value_test.go
Normal 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())
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue