664f7a0de0
Following TDD principles, adding tests before implementation: - Add HabitType value object tests (validation) - Add Frequency value object tests (validation) - Add User entity tests (creation, default timezone) - Add Habit entity tests (creation, archive, active status) - Add HabitEntry entity tests (creation, soft delete) Tests cover core domain logic and business rules. All tests will fail until implementation is added.
27 lines
706 B
Go
27 lines
706 B
Go
package value_objects
|
|
|
|
import "testing"
|
|
|
|
func TestFrequency_IsValid(t *testing.T) {
|
|
tests := []struct {
|
|
name string
|
|
freq Frequency
|
|
expected bool
|
|
}{
|
|
{"Daily frequency is valid", FrequencyDaily, true},
|
|
{"Weekly frequency is valid", FrequencyWeekly, true},
|
|
{"Monthly frequency is valid", FrequencyMonthly, true},
|
|
{"Empty string is invalid", Frequency(""), false},
|
|
{"Random string is invalid", Frequency("YEARLY"), false},
|
|
{"Lowercase is invalid", Frequency("daily"), false},
|
|
}
|
|
|
|
for _, tt := range tests {
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
if got := tt.freq.IsValid(); got != tt.expected {
|
|
t.Errorf("Frequency.IsValid() = %v, want %v", got, tt.expected)
|
|
}
|
|
})
|
|
}
|
|
}
|