5d92820591
Timezone is now sent from the client on each request that needs it, instead of storing it in the database. This simplifies the model and allows timezone to be dynamic (useful for traveling users). Changes: - Remove timezone field from User entity - Remove timezone from user registration - GET /habits/today now requires ?timezone= query param - Add migration to drop timezone column from database - Update related tests
35 lines
723 B
Go
35 lines
723 B
Go
package entities
|
|
|
|
import (
|
|
"testing"
|
|
"time"
|
|
)
|
|
|
|
func TestNewUser(t *testing.T) {
|
|
email := "test@example.com"
|
|
passwordHash := "hashed_password_123"
|
|
|
|
user := NewUser(email, passwordHash)
|
|
|
|
if user.Email != email {
|
|
t.Errorf("Expected email %s, got %s", email, user.Email)
|
|
}
|
|
|
|
if user.PasswordHash != passwordHash {
|
|
t.Errorf("Expected password hash %s, got %s", passwordHash, user.PasswordHash)
|
|
}
|
|
|
|
if user.CreatedAt.IsZero() {
|
|
t.Error("CreatedAt should not be zero")
|
|
}
|
|
|
|
if user.UpdatedAt.IsZero() {
|
|
t.Error("UpdatedAt should not be zero")
|
|
}
|
|
|
|
diff := user.UpdatedAt.Sub(user.CreatedAt)
|
|
if diff < 0 || diff > time.Second {
|
|
t.Errorf("CreatedAt and UpdatedAt should be nearly identical, diff: %v", diff)
|
|
}
|
|
}
|