chore: initial commit of HouseholdBudgetBook (backend, frontend, desktop)
This commit is contained in:
commit
4a5db3f1f9
167 files changed
+21732
No files matched your search
@@ -0,0 +1,27 @@
|
||||
package service
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestValidateTransactionFields(t *testing.T) {
|
||||
one, two := int64(1), int64(2)
|
||||
cases := []struct {
|
||||
name, typ string
|
||||
category, from, to *int64
|
||||
wantErr bool
|
||||
}{
|
||||
{"expense", "expense", &one, &one, nil, false},
|
||||
{"transfer", "transfer", nil, &one, &two, false},
|
||||
{"transfer category", "transfer", &one, &one, &two, true},
|
||||
{"transfer same account", "transfer", nil, &one, &one, true},
|
||||
{"expense without category", "expense", nil, &one, nil, true},
|
||||
{"expense with target", "expense", &one, &one, &two, true},
|
||||
}
|
||||
for _, tc := range cases {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
err := validateTransactionFields(tc.typ, tc.category, tc.from, tc.to)
|
||||
if (err != nil) != tc.wantErr {
|
||||
t.Fatalf("error=%v wantErr=%v", err, tc.wantErr)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user