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

Commitff4d5c1

Browse files
committed
chore: padding on golden file timestamps
Making the replacement the same length keeps table formats the samein a golden file.
1 parent2cb9bfd commitff4d5c1

File tree

4 files changed

+24
-16
lines changed

4 files changed

+24
-16
lines changed

‎cli/clitest/golden.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,15 @@ ExtractCommandPathsLoop:
122122
// equality check.
123123
funcNormalizeGoldenFile(t*testing.T,byt []byte) []byte {
124124
// Replace any timestamps with a placeholder.
125-
byt=timestampRegex.ReplaceAll(byt, []byte("[timestamp]"))
125+
byt=timestampRegex.ReplaceAllFunc(byt,func(source []byte) []byte {
126+
// Pad the timestamps to maintain the same length. This is mainly for tabled
127+
// output where the padding is important for alignment.
128+
lenSrc:=len(source)
129+
rpl:="timestamp"
130+
required:=lenSrc-2
131+
132+
return []byte("["+fmt.Sprintf("%-*s",required,rpl)+"]")
133+
})
126134

127135
homeDir,err:=os.UserHomeDir()
128136
require.NoError(t,err)

‎cli/testdata/coder_list_--output_json.golden

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
[
22
{
33
"id": "[workspace ID]",
4-
"created_at": "[timestamp]",
5-
"updated_at": "[timestamp]",
4+
"created_at": "[timestamp]",
5+
"updated_at": "[timestamp]",
66
"owner_id": "[first user ID]",
77
"owner_name": "testuser",
88
"owner_avatar_url": "",
@@ -16,8 +16,8 @@
1616
"template_require_active_version": false,
1717
"latest_build": {
1818
"id": "[workspace build ID]",
19-
"created_at": "[timestamp]",
20-
"updated_at": "[timestamp]",
19+
"created_at": "[timestamp]",
20+
"updated_at": "[timestamp]",
2121
"workspace_id": "[workspace ID]",
2222
"workspace_name": "test-workspace",
2323
"workspace_owner_id": "[first user ID]",
@@ -31,9 +31,9 @@
3131
"initiator_name": "testuser",
3232
"job": {
3333
"id": "[workspace build job ID]",
34-
"created_at": "[timestamp]",
35-
"started_at": "[timestamp]",
36-
"completed_at": "[timestamp]",
34+
"created_at": "[timestamp]",
35+
"started_at": "[timestamp]",
36+
"completed_at": "[timestamp]",
3737
"status": "succeeded",
3838
"worker_id": "[workspace build worker ID]",
3939
"file_id": "[workspace build file ID]",
@@ -46,7 +46,7 @@
4646
},
4747
"reason": "initiator",
4848
"resources": [],
49-
"deadline": "[timestamp]",
49+
"deadline": "[timestamp]",
5050
"max_deadline": null,
5151
"status": "running",
5252
"daily_cost": 0
@@ -55,7 +55,7 @@
5555
"name": "test-workspace",
5656
"autostart_schedule": "CRON_TZ=US/Central 30 9 * * 1-5",
5757
"ttl_ms": 28800000,
58-
"last_used_at": "[timestamp]",
58+
"last_used_at": "[timestamp]",
5959
"deleting_at": null,
6060
"dormant_at": null,
6161
"health": {

‎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: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
"avatar_url": "",
66
"name": "",
77
"email": "testuser@coder.com",
8-
"created_at": "[timestamp]",
9-
"last_seen_at": "[timestamp]",
8+
"created_at": "[timestamp]",
9+
"last_seen_at": "[timestamp]",
1010
"status": "active",
1111
"login_type": "password",
1212
"theme_preference": "",
@@ -26,8 +26,8 @@
2626
"avatar_url": "",
2727
"name": "",
2828
"email": "testuser2@coder.com",
29-
"created_at": "[timestamp]",
30-
"last_seen_at": "[timestamp]",
29+
"created_at": "[timestamp]",
30+
"last_seen_at": "[timestamp]",
3131
"status": "dormant",
3232
"login_type": "password",
3333
"theme_preference": "",

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp