Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit92eab7e

Browse files
committed
extra tests
1 parenta00c350 commit92eab7e

File tree

2 files changed

+31
-3
lines changed

2 files changed

+31
-3
lines changed

‎Coder-Desktop/Coder-Desktop/VPN/MenuState.swift

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,8 @@ struct Agent: Identifiable, Equatable, Comparable, Hashable {
8989

9090
extensionTimeInterval{
9191
varprettyPrintMs:String{
92-
Measurement(value:self*1000, unit:UnitDuration.milliseconds)
93-
.formatted(.measurement(width:.abbreviated,
94-
numberFormatStyle:.number.precision(.fractionLength(2))))
92+
letmilliseconds=self*1000
93+
return"\(milliseconds.formatted(.number.precision(.fractionLength(2)))) ms"
9594
}
9695
}
9796

‎Coder-Desktop/Coder-DesktopTests/VPNMenuStateTests.swift

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ struct VPNMenuStateTests {
2020
$0.lastHandshake=.init(date:Date.now)
2121
$0.lastPing=.with{
2222
$0.latency=.init(floatLiteral:0.05)
23+
$0.didP2P=true
2324
}
2425
$0.fqdn=["foo.coder"]
2526
}
@@ -32,6 +33,9 @@ struct VPNMenuStateTests {
3233
#expect(storedAgent.wsName=="foo")
3334
#expect(storedAgent.primaryHost=="foo.coder")
3435
#expect(storedAgent.status==.okay)
36+
#expect(storedAgent.statusString.contains("You're connected peer-to-peer."))
37+
#expect(storedAgent.statusString.contains("You ↔ 50.00 ms ↔ foo"))
38+
#expect(storedAgent.statusString.contains("Last handshake: Just now"))
3539
}
3640

3741
@Test
@@ -98,6 +102,26 @@ struct VPNMenuStateTests {
98102
#expect(storedAgent.status==.warn)
99103
}
100104

105+
@Test
106+
mutatingfunc testUpsertAgent_connecting()asyncthrows{
107+
letagentID=UUID()
108+
letworkspaceID=UUID()
109+
state.upsertWorkspace(Vpn_Workspace.with{ $0.id= workspaceID.uuidData; $0.name="foo"})
110+
111+
letagent=Vpn_Agent.with{
112+
$0.id= agentID.uuidData
113+
$0.workspaceID= workspaceID.uuidData
114+
$0.name="agent1"
115+
$0.lastHandshake=.init()
116+
$0.fqdn=["foo.coder"]
117+
}
118+
119+
state.upsertAgent(agent)
120+
121+
letstoredAgent=try #require(state.agents[agentID])
122+
#expect(storedAgent.status==.connecting)
123+
}
124+
101125
@Test
102126
mutatingfunc testUpsertAgent_unhealthyAgent()asyncthrows{
103127
letagentID=UUID()
@@ -176,6 +200,7 @@ struct VPNMenuStateTests {
176200
$0.name="agent1"
177201
$0.lastHandshake=.init(date:Date.now.addingTimeInterval(-200))
178202
$0.lastPing=.with{
203+
$0.didP2P=false
179204
$0.latency=.init(floatLiteral:0.05)
180205
}
181206
$0.fqdn=["foo.coder"]
@@ -187,6 +212,10 @@ struct VPNMenuStateTests {
187212
#expect(output[0].id== agentID)
188213
#expect(output[0].wsName=="foo")
189214
#expect(output[0].status==.okay)
215+
letstoredAgentFromSort=try #require(state.agents[agentID])
216+
#expect(storedAgentFromSort.statusString.contains("You're connected through a DERP relay."))
217+
#expect(storedAgentFromSort.statusString.contains("Total latency: 50.00 ms"))
218+
#expect(storedAgentFromSort.statusString.contains("Last handshake: 3 minutes ago"))
190219
}
191220

192221
@Test

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp