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

Commitd59fddb

Browse files
authored
test(cli/clitest): pad replacements for table alignment (#15942)
1 parent63572d9 commitd59fddb

File tree

4 files changed

+61
-51
lines changed

4 files changed

+61
-51
lines changed

‎cli/clitest/golden.go

Lines changed: 25 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ func TestGoldenFile(t *testing.T, fileName string, actual []byte, replacements m
128128
// equality check.
129129
funcnormalizeGoldenFile(t*testing.T,byt []byte) []byte {
130130
// Replace any timestamps with a placeholder.
131-
byt=timestampRegex.ReplaceAll(byt, []byte("[timestamp]"))
131+
byt=timestampRegex.ReplaceAll(byt, []byte(pad("[timestamp]",20)))
132132

133133
homeDir,err:=os.UserHomeDir()
134134
require.NoError(t,err)
@@ -202,21 +202,31 @@ func prepareTestData(t *testing.T) (*codersdk.Client, map[string]string) {
202202
workspaceBuild:=coderdtest.AwaitWorkspaceBuildJobCompleted(t,rootClient,workspace.LatestBuild.ID)
203203

204204
replacements:=map[string]string{
205-
firstUser.UserID.String():"[first user ID]",
206-
secondUser.ID.String():"[second user ID]",
207-
firstUser.OrganizationID.String():"[first org ID]",
208-
version.ID.String():"[version ID]",
209-
version.Name:"[version name]",
210-
version.Job.ID.String():"[version job ID]",
211-
version.Job.FileID.String():"[version file ID]",
212-
version.Job.WorkerID.String():"[version worker ID]",
213-
template.ID.String():"[template ID]",
214-
workspace.ID.String():"[workspace ID]",
215-
workspaceBuild.ID.String():"[workspace build ID]",
216-
workspaceBuild.Job.ID.String():"[workspace build job ID]",
217-
workspaceBuild.Job.FileID.String():"[workspace build file ID]",
218-
workspaceBuild.Job.WorkerID.String():"[workspace build worker ID]",
205+
firstUser.UserID.String():pad("[first user ID]",36),
206+
secondUser.ID.String():pad("[second user ID]",36),
207+
firstUser.OrganizationID.String():pad("[first org ID]",36),
208+
version.ID.String():pad("[version ID]",36),
209+
version.Name:pad("[version name]",36),
210+
version.Job.ID.String():pad("[version job ID]",36),
211+
version.Job.FileID.String():pad("[version file ID]",36),
212+
version.Job.WorkerID.String():pad("[version worker ID]",36),
213+
template.ID.String():pad("[template ID]",36),
214+
workspace.ID.String():pad("[workspace ID]",36),
215+
workspaceBuild.ID.String():pad("[workspace build ID]",36),
216+
workspaceBuild.Job.ID.String():pad("[workspace build job ID]",36),
217+
workspaceBuild.Job.FileID.String():pad("[workspace build file ID]",36),
218+
workspaceBuild.Job.WorkerID.String():pad("[workspace build worker ID]",36),
219219
}
220220

221221
returnrootClient,replacements
222222
}
223+
224+
funcpad(sstring,nint)string {
225+
iflen(s)>=n {
226+
returns
227+
}
228+
n-=len(s)
229+
pre:=n/2
230+
post:=n-pre
231+
returnstrings.Repeat("=",pre)+s+strings.Repeat("=",post)
232+
}
Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,43 @@
11
[
22
{
3-
"id": "[workspace ID]",
4-
"created_at": "[timestamp]",
5-
"updated_at": "[timestamp]",
6-
"owner_id": "[first user ID]",
3+
"id": "===========[workspace ID]===========",
4+
"created_at": "====[timestamp]=====",
5+
"updated_at": "====[timestamp]=====",
6+
"owner_id": "==========[first user ID]===========",
77
"owner_name": "testuser",
88
"owner_avatar_url": "",
9-
"organization_id": "[first org ID]",
9+
"organization_id": "===========[first org ID]===========",
1010
"organization_name": "coder",
11-
"template_id": "[template ID]",
11+
"template_id": "===========[template ID]============",
1212
"template_name": "test-template",
1313
"template_display_name": "",
1414
"template_icon": "",
1515
"template_allow_user_cancel_workspace_jobs": false,
16-
"template_active_version_id": "[version ID]",
16+
"template_active_version_id": "============[version ID]============",
1717
"template_require_active_version": false,
1818
"latest_build": {
19-
"id": "[workspace build ID]",
20-
"created_at": "[timestamp]",
21-
"updated_at": "[timestamp]",
22-
"workspace_id": "[workspace ID]",
19+
"id": "========[workspace build ID]========",
20+
"created_at": "====[timestamp]=====",
21+
"updated_at": "====[timestamp]=====",
22+
"workspace_id": "===========[workspace ID]===========",
2323
"workspace_name": "test-workspace",
24-
"workspace_owner_id": "[first user ID]",
24+
"workspace_owner_id": "==========[first user ID]===========",
2525
"workspace_owner_name": "testuser",
2626
"workspace_owner_avatar_url": "",
27-
"template_version_id": "[version ID]",
28-
"template_version_name": "[version name]",
27+
"template_version_id": "============[version ID]============",
28+
"template_version_name": "===========[version name]===========",
2929
"build_number": 1,
3030
"transition": "start",
31-
"initiator_id": "[first user ID]",
31+
"initiator_id": "==========[first user ID]===========",
3232
"initiator_name": "testuser",
3333
"job": {
34-
"id": "[workspace build job ID]",
35-
"created_at": "[timestamp]",
36-
"started_at": "[timestamp]",
37-
"completed_at": "[timestamp]",
34+
"id": "======[workspace build job ID]======",
35+
"created_at": "====[timestamp]=====",
36+
"started_at": "====[timestamp]=====",
37+
"completed_at": "====[timestamp]=====",
3838
"status": "succeeded",
39-
"worker_id": "[workspace build worker ID]",
40-
"file_id": "[workspace build file ID]",
39+
"worker_id": "====[workspace build worker ID]=====",
40+
"file_id": "=====[workspace build file ID]======",
4141
"tags": {
4242
"owner": "",
4343
"scope": "organization"
@@ -47,7 +47,7 @@
4747
},
4848
"reason": "initiator",
4949
"resources": [],
50-
"deadline": "[timestamp]",
50+
"deadline": "====[timestamp]=====",
5151
"max_deadline": null,
5252
"status": "running",
5353
"daily_cost": 0,
@@ -61,7 +61,7 @@
6161
"name": "test-workspace",
6262
"autostart_schedule": "CRON_TZ=US/Central 30 9 * * 1-5",
6363
"ttl_ms": 28800000,
64-
"last_used_at": "[timestamp]",
64+
"last_used_at": "====[timestamp]=====",
6565
"deleting_at": null,
6666
"dormant_at": null,
6767
"health": {
@@ -71,6 +71,6 @@
7171
"automatic_updates": "never",
7272
"allow_renames": false,
7373
"favorite": false,
74-
"next_start_at": "[timestamp]"
74+
"next_start_at": "====[timestamp]====="
7575
}
7676
]

‎cli/testdata/coder_users_list.golden

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
USERNAME EMAIL CREATED AT STATUS
2-
testuser testuser@coder.com [timestamp] active
3-
testuser2 testuser2@coder.com [timestamp] dormant
2+
testuser testuser@coder.com====[timestamp]===== active
3+
testuser2 testuser2@coder.com====[timestamp]===== dormant

‎cli/testdata/coder_users_list_--output_json.golden

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
[
22
{
3-
"id": "[first user ID]",
3+
"id": "==========[first user ID]===========",
44
"username": "testuser",
55
"avatar_url": "",
66
"name": "Test User",
77
"email": "testuser@coder.com",
8-
"created_at": "[timestamp]",
9-
"updated_at": "[timestamp]",
10-
"last_seen_at": "[timestamp]",
8+
"created_at": "====[timestamp]=====",
9+
"updated_at": "====[timestamp]=====",
10+
"last_seen_at": "====[timestamp]=====",
1111
"status": "active",
1212
"login_type": "password",
1313
"theme_preference": "",
1414
"organization_ids": [
15-
"[first org ID]"
15+
"===========[first org ID]==========="
1616
],
1717
"roles": [
1818
{
@@ -22,19 +22,19 @@
2222
]
2323
},
2424
{
25-
"id": "[second user ID]",
25+
"id": "==========[second user ID]==========",
2626
"username": "testuser2",
2727
"avatar_url": "",
2828
"name": "",
2929
"email": "testuser2@coder.com",
30-
"created_at": "[timestamp]",
31-
"updated_at": "[timestamp]",
32-
"last_seen_at": "[timestamp]",
30+
"created_at": "====[timestamp]=====",
31+
"updated_at": "====[timestamp]=====",
32+
"last_seen_at": "====[timestamp]=====",
3333
"status": "dormant",
3434
"login_type": "password",
3535
"theme_preference": "",
3636
"organization_ids": [
37-
"[first org ID]"
37+
"===========[first org ID]==========="
3838
],
3939
"roles": []
4040
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp