v / .github / show_manual_release_cmd_test.v
30 lines · 27 sloc · 942 bytes · 5b69150b3efa1dbb15d019830c5ba7a1febe8e61
Raw
1module main
2
3import os
4
5fn show_release_tag_for(now string) string {
6 script_path := os.join_path(os.dir(@FILE), 'workflows', 'show_manual_release_cmd.vsh')
7 cmd := 'V_RELEASE_TAG_NOW="${now}" ${os.quoted_path(@VEXE)} run ${os.quoted_path(script_path)}'
8 res := os.execute(cmd)
9 assert res.exit_code == 0, res.output
10 for line in res.output.split_into_lines() {
11 if line.contains('current release_tag: ') {
12 return line.all_after('current release_tag: ')
13 }
14 }
15 panic('missing release tag in output:\n${res.output}')
16}
17
18fn test_show_manual_release_cmd_uses_iso_week_year() {
19 test_cases := {
20 '2025-12-28 00:00:00': 'weekly.2025.52'
21 '2025-12-29 00:00:00': 'weekly.2026.01'
22 '2025-12-31 00:00:00': 'weekly.2026.01'
23 '2026-01-01 00:00:00': 'weekly.2026.01'
24 '2026-01-04 00:00:00': 'weekly.2026.01'
25 '2026-01-05 00:00:00': 'weekly.2026.02'
26 }
27 for input, expected in test_cases {
28 assert show_release_tag_for(input) == expected
29 }
30}
31