Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F33103614
backup_view_test.exs
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
backup_view_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.Web.PleromaAPI.BackupViewTest
do
use
Pleroma.DataCase
,
async
:
true
alias
Pleroma.UnstubbedConfigMock
,
as
:
ConfigMock
alias
Pleroma.User.Backup
alias
Pleroma.Web.PleromaAPI.BackupView
import
Mox
import
Pleroma.Factory
setup
do
ConfigMock
|>
stub_with
(
Pleroma.Test.StaticConfig
)
:ok
end
test
"it renders the ID"
do
user
=
insert
(
:user
)
backup
=
Backup
.
new
(
user
)
result
=
BackupView
.
render
(
"show.json"
,
backup
:
backup
)
assert
result
.
id
==
backup
.
id
end
test
"it renders the state and processed_number"
do
user
=
insert
(
:user
)
backup
=
Backup
.
new
(
user
)
result
=
BackupView
.
render
(
"show.json"
,
backup
:
backup
)
assert
result
.
state
==
to_string
(
backup
.
state
)
assert
result
.
processed_number
==
backup
.
processed_number
end
test
"it renders failed state with legacy records"
do
backup
=
%
Backup
{
id
:
0
,
content_type
:
"application/zip"
,
file_name
:
"dummy"
,
file_size
:
1
,
state
:
:invalid
,
processed
:
true
,
processed_number
:
1
,
inserted_at
:
NaiveDateTime
.
utc_now
()
}
result
=
BackupView
.
render
(
"show.json"
,
backup
:
backup
)
assert
result
.
state
==
"complete"
backup
=
%
Backup
{
id
:
0
,
content_type
:
"application/zip"
,
file_name
:
"dummy"
,
file_size
:
1
,
state
:
:invalid
,
processed
:
false
,
processed_number
:
1
,
inserted_at
:
NaiveDateTime
.
utc_now
()
}
result
=
BackupView
.
render
(
"show.json"
,
backup
:
backup
)
assert
result
.
state
==
"failed"
end
end
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Tue, Jan 20, 2:00 PM (2 h, 46 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
973813
Default Alt Text
backup_view_test.exs (1 KB)
Attached To
Mode
rPUBE pleroma-upstream
Attached
Detach File
Event Timeline
Log In to Comment