Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F162747
date_time_test.exs
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Award Token
Flag For Later
Size
998 B
Referenced Files
None
Subscribers
None
date_time_test.exs
View Options
# Pleroma: A lightweight social networking server
# Copyright © 2017-2022 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only
defmodule
Pleroma.EctoType.ActivityPub.ObjectValidators.DateTimeTest
do
alias
Pleroma.EctoType.ActivityPub.ObjectValidators.DateTime
use
Pleroma.DataCase
,
async
:
true
test
"it validates an xsd:Datetime"
do
valid_strings
=
[
"2004-04-12T13:20:00"
,
"2004-04-12T13:20:15.5"
,
"2004-04-12T13:20:00-05:00"
,
"2004-04-12T13:20:00Z"
]
invalid_strings
=
[
"2004-04-12T13:00"
,
"2004-04-1213:20:00"
,
"99-04-12T13:00"
,
"2004-04-12"
]
assert
{
:ok
,
"2004-04-01T12:00:00Z"
}
==
DateTime
.
cast
(
"2004-04-01T12:00:00Z"
)
Enum
.
each
(
valid_strings
,
fn
date_time
->
result
=
DateTime
.
cast
(
date_time
)
assert
{
:ok
,
_
}
=
result
end
)
Enum
.
each
(
invalid_strings
,
fn
date_time
->
result
=
DateTime
.
cast
(
date_time
)
assert
:error
==
result
end
)
end
end
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Fri, Feb 21, 5:51 PM (13 h, 6 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
66824
Default Alt Text
date_time_test.exs (998 B)
Attached To
Mode
rPUBE pleroma-upstream
Attached
Detach File
Event Timeline
Log In to Comment