35 lines
998 B
Swift
35 lines
998 B
Swift
import Testing
|
|||
|
|
|
||
|
|
@testable import Persistence
|
||
|
|
|
||
|
|
@Suite(
|
||
|
|
"AccountRepository repository",
|
||
|
|
.tags(.repository)
|
||
|
|
)
|
||
|
|
struct AccountRepositoryTests {
|
||
|
|
|
||
|
|
// MARK: Methods tests
|
||
|
|
|
||
|
|
@Test
|
||
|
|
func `finds the seeded demo buyer`() async throws {
|
||
|
|
try await withDatabase { fluent in
|
||
|
|
let user = try await AccountRepository(fluent: fluent).account(email: AccountRepository.demoEmail)
|
||
|
|
|
||
|
|
#expect(user.email == "mara.v@example.com")
|
||
|
|
#expect(user.displayName == "Mara Visser")
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
@Test
|
||
|
|
func `joins an unknown email once, named after its local part`() async throws {
|
||
|
|
try await withDatabase { fluent in
|
||
|
|
let repository = AccountRepository(fluent: fluent)
|
||
|
|
let joined = try await repository.account(email: "sam@example.com")
|
||
|
|
let returning = try await repository.account(email: "sam@example.com")
|
||
|
|
|
||
|
|
#expect(joined.displayName == "sam")
|
||
|
|
#expect(returning == joined)
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
}
|