Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F45709818
config_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
config_test.exs
View Options
defmodule
Mix.Tasks.Pleroma.ConfigTest
do
use
Pleroma.DataCase
alias
Pleroma.Repo
alias
Pleroma.Web.AdminAPI.Config
setup_all
do
Mix
.
shell
(
Mix.Shell.Process
)
temp_file
=
"config/temp.exported_from_db.secret.exs"
dynamic
=
Pleroma.Config
.
get
([
:instance
,
:dynamic_configuration
])
Pleroma.Config
.
put
([
:instance
,
:dynamic_configuration
],
true
)
on_exit
(
fn
->
Mix
.
shell
(
Mix.Shell.IO
)
Application
.
delete_env
(
:pleroma
,
:first_setting
)
Application
.
delete_env
(
:pleroma
,
:second_setting
)
Pleroma.Config
.
put
([
:instance
,
:dynamic_configuration
],
dynamic
)
:ok
=
File
.
rm
(
temp_file
)
end
)
{
:ok
,
temp_file
:
temp_file
}
end
test
"settings are migrated to db"
do
assert
Repo
.
all
(
Config
)
==
[]
Application
.
put_env
(
:pleroma
,
:first_setting
,
key
:
"value"
,
key2
:
[
Pleroma.Repo
])
Application
.
put_env
(
:pleroma
,
:second_setting
,
key
:
"value2"
,
key2
:
[
Pleroma.Activity
])
Mix.Tasks.Pleroma.Config
.
run
([
"migrate_to_db"
])
first_db
=
Config
.
get_by_key
(
"first_setting"
)
second_db
=
Config
.
get_by_key
(
"second_setting"
)
refute
Config
.
get_by_key
(
"Pleroma.Repo"
)
assert
Config
.
from_binary
(
first_db
.
value
)
==
[
key
:
"value"
,
key2
:
[
Pleroma.Repo
]]
assert
Config
.
from_binary
(
second_db
.
value
)
==
[
key
:
"value2"
,
key2
:
[
Pleroma.Activity
]]
end
test
"settings are migrated to file and deleted from db"
,
%{
temp_file
:
temp_file
}
do
Config
.
create
(%{
key
:
"setting_first"
,
value
:
[
key
:
"value"
,
key2
:
[
Pleroma.Activity
]]})
Config
.
create
(%{
key
:
"setting_second"
,
value
:
[
key
:
"valu2"
,
key2
:
[
Pleroma.Repo
]]})
Mix.Tasks.Pleroma.Config
.
run
([
"migrate_from_db"
,
"temp"
])
assert
Repo
.
all
(
Config
)
==
[]
assert
File
.
exists?
(
temp_file
)
{
:ok
,
file
}
=
File
.
read
(
temp_file
)
assert
file
=~
"config :pleroma, setting_first:"
assert
file
=~
"config :pleroma, setting_second:"
end
end
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Mar 7, 11:14 AM (10 h, 28 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1165428
Default Alt Text
config_test.exs (1 KB)
Attached To
Mode
rPUBE pleroma-upstream
Attached
Detach File
Event Timeline
Log In to Comment