Files

43 lines
1.5 KiB
Go

//go:build e2e
package postgres
import (
"testing"
"time"
"lincodex/backend/internal/domain"
)
func TestIsCompanyFixtureEmployerRequiresVerifiedSyntheticEmployer(t *testing.T) {
verifiedAt := time.Date(2026, time.October, 7, 12, 0, 0, 0, time.UTC)
tests := []struct {
name string
email string
scenario domain.Scenario
verified bool
want bool
}{
{name: "verified fixture employer", email: "company-abcdef12@example.test", scenario: domain.ScenarioEmployer, verified: true, want: true},
{name: "unverified employer", email: "company-abcdef12@example.test", scenario: domain.ScenarioEmployer},
{name: "candidate account", email: "company-abcdef12@example.test", scenario: domain.ScenarioCandidate, verified: true},
{name: "ordinary employer", email: "employer@example.test", scenario: domain.ScenarioEmployer, verified: true},
{name: "fixture-like address with wrong suffix", email: "company-abcdef12@example.org", scenario: domain.ScenarioEmployer, verified: true},
}
for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
address, err := domain.NewEmailAddress(test.email)
if err != nil {
t.Fatalf("NewEmailAddress() error = %v", err)
}
user := domain.User{Email: address, Scenario: test.scenario}
if test.verified {
user.EmailVerifiedAt = &verifiedAt
}
if got := isCompanyFixtureEmployer(user); got != test.want {
t.Fatalf("isCompanyFixtureEmployer() = %t, want %t", got, test.want)
}
})
}
}