Add domain layer tests (TDD - Red phase)

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.
This commit is contained in:
2025-11-25 10:12:04 +01:00
parent 4d5652a5a4
commit 664f7a0de0
5 changed files with 272 additions and 0 deletions
@@ -0,0 +1,26 @@
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)
}
})
}
}
@@ -0,0 +1,26 @@
package value_objects
import "testing"
func TestHabitType_IsValid(t *testing.T) {
tests := []struct {
name string
habType HabitType
expected bool
}{
{"Boolean type is valid", HabitTypeBoolean, true},
{"Counter type is valid", HabitTypeCounter, true},
{"Value type is valid", HabitTypeValue, true},
{"Empty string is invalid", HabitType(""), false},
{"Random string is invalid", HabitType("RANDOM"), false},
{"Lowercase is invalid", HabitType("boolean"), false},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := tt.habType.IsValid(); got != tt.expected {
t.Errorf("HabitType.IsValid() = %v, want %v", got, tt.expected)
}
})
}
}