Files
honeyDueAPI/internal/models/user_test.go
T
Trey t 81578f6e27
Backend CI / Test (push) Has been cancelled
Backend CI / Contract Tests (push) Has been cancelled
Backend CI / Lint (push) Has been cancelled
Backend CI / Secret Scanning (push) Has been cancelled
Backend CI / Build (push) Has been cancelled
feat(auth): replace hand-rolled auth with Ory Kratos — phase 2 backend
Delegates all credential management (login, register, password reset,
email verification, social sign-in) to Ory Kratos. The Go API now acts
as a resource server: the new KratosAuth middleware validates sessions
against the Kratos whoami endpoint, writes the local User mirror into
Echo context, and all existing domain handlers continue working
unchanged. Hand-rolled token auth, AuthToken model, apple_auth/
google_auth services, and the auth refresh flow are removed. Tests are
updated to use the fake-token middleware pattern so existing integration
assertions require no rewrite.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-18 17:55:56 -05:00

54 lines
1.1 KiB
Go

package models
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestUser_GetFullName(t *testing.T) {
tests := []struct {
name string
user User
expected string
}{
{
name: "first and last name",
user: User{FirstName: "John", LastName: "Doe", Username: "johndoe"},
expected: "John Doe",
},
{
name: "first name only",
user: User{FirstName: "John", LastName: "", Username: "johndoe"},
expected: "John",
},
{
name: "username fallback",
user: User{FirstName: "", LastName: "", Username: "johndoe"},
expected: "johndoe",
},
{
name: "last name only returns username",
user: User{FirstName: "", LastName: "Doe", Username: "johndoe"},
expected: "johndoe",
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
result := tt.user.GetFullName()
assert.Equal(t, tt.expected, result)
})
}
}
func TestUser_TableName(t *testing.T) {
user := User{}
assert.Equal(t, "auth_user", user.TableName())
}
func TestUserProfile_TableName(t *testing.T) {
profile := UserProfile{}
assert.Equal(t, "user_userprofile", profile.TableName())
}