Files
pulse-api/internal/service/helpers_test.go
Cosmo 8d9fe818f4
All checks were successful
CI / ci (push) Successful in 35s
Add unit tests for middleware, models, services, handlers, and repository helpers
2026-03-01 02:32:59 +00:00

36 lines
685 B
Go

package service
import "testing"
func TestDefaultString(t *testing.T) {
tests := []struct {
val, def, want string
}{
{"hello", "default", "hello"},
{"", "default", "default"},
{"", "", ""},
}
for _, tt := range tests {
got := defaultString(tt.val, tt.def)
if got != tt.want {
t.Errorf("defaultString(%q, %q) = %q, want %q", tt.val, tt.def, got, tt.want)
}
}
}
func TestDefaultInt(t *testing.T) {
tests := []struct {
val, def, want int
}{
{5, 10, 5},
{0, 10, 10},
{0, 0, 0},
}
for _, tt := range tests {
got := defaultInt(tt.val, tt.def)
if got != tt.want {
t.Errorf("defaultInt(%d, %d) = %d, want %d", tt.val, tt.def, got, tt.want)
}
}
}