mirror of
https://github.com/lune-org/lune.git
synced 2025-05-04 10:43:57 +01:00
fix(tests): put locale tests behind flag lock
This commit is contained in:
parent
d3dd11313f
commit
fcb2057115
1 changed files with 22 additions and 7 deletions
|
@ -8,12 +8,6 @@ assert(
|
||||||
"invalid ISO 8601 formatting for DateTime.formatTime() (UTC)"
|
"invalid ISO 8601 formatting for DateTime.formatTime() (UTC)"
|
||||||
)
|
)
|
||||||
|
|
||||||
assert(
|
|
||||||
DateTime.fromUnixTimestamp(1693068988):formatTime("utc", "%A, %d %B %Y", "fr")
|
|
||||||
== "samedi, 26 août 2023",
|
|
||||||
"expected format specifier '%A, %d %B %Y' to return 'samedi, 26 août 2023' for locale 'fr' (UTC)"
|
|
||||||
)
|
|
||||||
|
|
||||||
local expectedTimeString = os.date("%Y-%m-%dT%H:%M:%SZ", 1694078954)
|
local expectedTimeString = os.date("%Y-%m-%dT%H:%M:%SZ", 1694078954)
|
||||||
|
|
||||||
assert(
|
assert(
|
||||||
|
@ -23,7 +17,7 @@ assert(
|
||||||
)
|
)
|
||||||
|
|
||||||
-- This test requires 'fr_FR.UTF-8 UTF-8' to be in /etc/locale.gen to pass
|
-- This test requires 'fr_FR.UTF-8 UTF-8' to be in /etc/locale.gen to pass
|
||||||
-- Locale should be set up by a script, or by the user, or in CI, test runner
|
-- Locale should be set up by a script, or by the user, or in CI, test runner
|
||||||
-- takes no responsibility for this
|
-- takes no responsibility for this
|
||||||
|
|
||||||
-- Local Timezone
|
-- Local Timezone
|
||||||
|
@ -34,6 +28,21 @@ assert(
|
||||||
"invalid ISO 8601 formatting for DateTime.formatTime() (local)"
|
"invalid ISO 8601 formatting for DateTime.formatTime() (local)"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
-- To run tests related to locales, one must explicitly
|
||||||
|
-- provide the `--test-locales` flag
|
||||||
|
local toTestLocales = false
|
||||||
|
|
||||||
|
for _, arg in process.args do
|
||||||
|
if arg == "--test-locales" then
|
||||||
|
toTestLocales = true
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if not toTestLocales then
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
|
||||||
local expectedLocalizedString
|
local expectedLocalizedString
|
||||||
|
|
||||||
local dateCmd = process.spawn("bash", { "-c", "date +\"%A, %d %B %Y\" --date='@1693068988'" }, {
|
local dateCmd = process.spawn("bash", { "-c", "date +\"%A, %d %B %Y\" --date='@1693068988'" }, {
|
||||||
|
@ -53,3 +62,9 @@ assert(
|
||||||
== expectedLocalizedString,
|
== expectedLocalizedString,
|
||||||
`expected format specifier '%A, %d %B %Y' to return '{expectedLocalizedString}' for locale 'fr' (local)`
|
`expected format specifier '%A, %d %B %Y' to return '{expectedLocalizedString}' for locale 'fr' (local)`
|
||||||
)
|
)
|
||||||
|
|
||||||
|
assert(
|
||||||
|
DateTime.fromUnixTimestamp(1693068988):formatTime("utc", "%A, %d %B %Y", "fr")
|
||||||
|
== "samedi, 26 août 2023",
|
||||||
|
"expected format specifier '%A, %d %B %Y' to return 'samedi, 26 août 2023' for locale 'fr' (UTC)"
|
||||||
|
)
|
||||||
|
|
Loading…
Add table
Reference in a new issue