Compare commits
75 Commits
newoffer20
...
main
| Author | SHA1 | Date |
|---|---|---|
|
|
3df4b37e52 | 5 days ago |
|
|
21359c2f56 | 2 weeks ago |
|
|
f0f04e9f64 | 2 weeks ago |
|
|
4d3679f95c | 2 weeks ago |
|
|
7608122bac | 2 weeks ago |
|
|
c2f58e93da | 3 weeks ago |
|
|
e994d17946 | 3 weeks ago |
|
|
6152c92d9a | 3 weeks ago |
|
|
25563982bb | 3 weeks ago |
|
|
dd7207ae33 | 3 weeks ago |
|
|
617bb91d6a | 3 weeks ago |
|
|
66abaeeb58 | 3 weeks ago |
|
|
9f66c3a769 | 3 weeks ago |
|
|
a17f3dee1c | 4 weeks ago |
|
|
d64ee6a7e0 | 4 weeks ago |
|
|
4842ad4572 | 4 weeks ago |
|
|
4fc4c2b41c | 4 weeks ago |
|
|
d321634069 | 4 weeks ago |
|
|
01e455d8b5 | 4 weeks ago |
|
|
df010931bc | 4 weeks ago |
|
|
4454a2c2d6 | 4 weeks ago |
|
|
54a35571b1 | 4 weeks ago |
|
|
ecf14eaa32 | 1 month ago |
|
|
1ef3faf5a2 | 1 month ago |
|
|
acc08e8b6b | 1 month ago |
|
|
b8407cb5c3 | 1 month ago |
|
|
2433dbb003 | 1 month ago |
|
|
a796902da5 | 1 month ago |
|
|
6f53d623bd | 1 month ago |
|
|
ed2dec6072 | 1 month ago |
|
|
45c24f3856 | 1 month ago |
|
|
ac9adad50f | 2 months ago |
|
|
ab80e6f7d6 | 2 months ago |
|
|
147ee5c059 | 2 months ago |
|
|
d45adf1937 | 2 months ago |
|
|
be94ebfc7f | 2 months ago |
|
|
f3d472512e | 2 months ago |
|
|
f813bc0a1b | 2 months ago |
|
|
306213e204 | 2 months ago |
|
|
f1d21b71ee | 2 months ago |
|
|
36dcbc9f30 | 2 months ago |
|
|
35b2c6c2a6 | 2 months ago |
|
|
e1fdf93176 | 2 months ago |
|
|
e3b3c6456c | 2 months ago |
|
|
b11905b168 | 2 months ago |
|
|
9ed8e56c2e | 2 months ago |
|
|
59642d1aca | 2 months ago |
|
|
4146886e85 | 2 months ago |
|
|
6ab981f334 | 2 months ago |
|
|
f67f283b5e | 2 months ago |
|
|
5ea1518e2e | 3 months ago |
|
|
5958662655 | 5 months ago |
|
|
5c7f74a384 | 5 months ago |
|
|
8f5761674c | 5 months ago |
|
|
8ac1d789fd | 5 months ago |
|
|
d5f5a7ee6e | 5 months ago |
|
|
2bef4ede0b | 5 months ago |
|
|
9bf546ac3d | 5 months ago |
|
|
866d822ecd | 5 months ago |
|
|
e41fa0873f | 5 months ago |
|
|
9a13378b91 | 5 months ago |
|
|
d7e63d0193 | 5 months ago |
|
|
1ca71b977f | 5 months ago |
|
|
c3d3c701bb | 5 months ago |
|
|
49cdab76ef | 5 months ago |
|
|
eff7e40198 | 5 months ago |
|
|
a0f3a35492 | 6 months ago |
|
|
9ca290bd13 | 6 months ago |
|
|
2b082252ab | 6 months ago |
|
|
1ed3c66f5d | 6 months ago |
|
|
17c94f8598 | 6 months ago |
|
|
5e7662552f | 6 months ago |
|
|
4ed4ca4ae3 | 6 months ago |
|
|
b5d8fe5033 | 6 months ago |
|
|
c30539390b | 6 months ago |
@ -0,0 +1,34 @@ |
||||
// |
||||
// Config.swift |
||||
// PadelClubData |
||||
// |
||||
// Created by Laurent Morvillier on 21/05/2025. |
||||
// |
||||
|
||||
@testable import PadelClubData |
||||
|
||||
class Config { |
||||
|
||||
var secure: Bool |
||||
var domain: String |
||||
|
||||
init(secure: Bool, domain: String) { |
||||
self.secure = secure |
||||
self.domain = domain |
||||
} |
||||
|
||||
static var server: Config { |
||||
|
||||
let bundle = Bundle(for: self) |
||||
|
||||
let secure = PListReader.readBool(plist: "config", key: "secure_server", bundle: bundle) |
||||
let domain = PListReader.readString(plist: "config", key: "server_domain", bundle: bundle) |
||||
|
||||
if let secure, let domain { |
||||
return Config(secure: secure, domain: domain) |
||||
} |
||||
|
||||
fatalError("no server configuration") |
||||
} |
||||
|
||||
} |
||||
@ -0,0 +1,101 @@ |
||||
// |
||||
// PadelClubDataTests.swift |
||||
// PadelClubDataTests |
||||
// |
||||
// Created by Laurent Morvillier on 15/04/2025. |
||||
// |
||||
|
||||
import Testing |
||||
@testable import PadelClubData |
||||
@testable import LeStorage |
||||
|
||||
enum TestError: Error { |
||||
case notAuthenticated |
||||
case sameDeviceId |
||||
case missingEvent |
||||
case missingTournament |
||||
} |
||||
|
||||
struct PadelClubDataTests { |
||||
|
||||
let username: String = "UserDataTests" |
||||
let password: String = "MyPass1234--" |
||||
|
||||
init() async throws { |
||||
|
||||
let conf = Config.server |
||||
|
||||
StoreCenter.main.configureURLs(secureScheme: conf.secure, domain: conf.domain) |
||||
StoreCenter.main.tokenKeychain = MockKeychainStore(fileName: "token.json") |
||||
try await self.login() |
||||
} |
||||
|
||||
mutating func login() async throws { |
||||
let _: CustomUser = try await StoreCenter.main.service().login(username: self.username, password: self.password) |
||||
} |
||||
|
||||
@Test func testAuthentication() { |
||||
#expect(StoreCenter.main.isAuthenticated) |
||||
} |
||||
|
||||
@Test func createTournament() async throws { |
||||
|
||||
guard let userId = StoreCenter.main.userId else { |
||||
throw TestError.notAuthenticated |
||||
} |
||||
|
||||
// Cleanup |
||||
let eventCol: SyncedCollection<Event> = await StoreCenter.main.mainStore.asyncLoadingSynchronizedCollection() |
||||
// let events: [Event] = try await StoreCenter.main.service().get() |
||||
try await eventCol.deleteAsync(contentOfs: Array(eventCol)) |
||||
#expect(eventCol.count == 0) |
||||
|
||||
let tournamentCol: SyncedCollection<Tournament> = await StoreCenter.main.mainStore.asyncLoadingSynchronizedCollection() |
||||
// let tournaments: [Tournament] = try await StoreCenter.main.service().get() |
||||
try await tournamentCol.deleteAsync(contentOfs: Array(tournamentCol)) |
||||
#expect(tournamentCol.count == 0) |
||||
|
||||
// Create |
||||
let event: Event = Event(creator: userId, club: nil, name: "test_createTournament") |
||||
try await eventCol.addOrUpdateAsync(instance: event) |
||||
|
||||
let tournament: Tournament = Tournament.fake() |
||||
tournament.event = event.id |
||||
try await tournamentCol.addOrUpdateAsync(instance: tournament) |
||||
|
||||
// Test server content |
||||
try await eventCol.loadOnceAsync() |
||||
#expect(eventCol.count == 1) |
||||
|
||||
try await tournamentCol.loadOnceAsync() |
||||
#expect(tournamentCol.count == 1) |
||||
|
||||
} |
||||
|
||||
@Test func dualStoreCenter() async throws { |
||||
|
||||
let conf = Config.server |
||||
|
||||
let secondStoreServer = StoreCenter() |
||||
secondStoreServer.configureURLs(secureScheme: conf.secure, domain: conf.domain) |
||||
secondStoreServer.tokenKeychain = MockKeychainStore(fileName: "token.json") |
||||
|
||||
let _: CustomUser = try await secondStoreServer.service().login(username: self.username, password: self.password) |
||||
|
||||
#expect(StoreCenter.main.isAuthenticated) |
||||
#expect(secondStoreServer.isAuthenticated) |
||||
|
||||
} |
||||
|
||||
@Test func testWebsocketSynchronization() async throws { |
||||
|
||||
let secondStoreServer = StoreCenter() |
||||
secondStoreServer.configureURLs(secureScheme: false, domain: "127.0.0.1:8000") |
||||
secondStoreServer.tokenKeychain = MockKeychainStore(fileName: "token.json") |
||||
|
||||
let events = DataStore.shared.events |
||||
try await DataStore.shared.events.deleteAsync(contentOfs: Array(events)) |
||||
|
||||
} |
||||
|
||||
} |
||||
File diff suppressed because it is too large
Load Diff
Loading…
Reference in new issue