Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
pleroma
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
NEETzsche
pleroma
Commits
4cac3854
Commit
4cac3854
authored
7 years ago
by
lain
Browse files
Options
Downloads
Patches
Plain Diff
Add factories for testing.
parent
1ccbe562
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
mix.exs
+1
-0
1 addition, 0 deletions
mix.exs
mix.lock
+1
-0
1 addition, 0 deletions
mix.lock
test/support/factory.ex
+47
-0
47 additions, 0 deletions
test/support/factory.ex
test/test_helper.exs
+1
-0
1 addition, 0 deletions
test/test_helper.exs
with
50 additions
and
0 deletions
mix.exs
+
1
−
0
View file @
4cac3854
...
...
@@ -38,6 +38,7 @@ defp deps do
{
:trailing_format_plug
,
"~> 0.0.5"
},
{
:html_sanitize_ex
,
"~> 1.0.0"
},
{
:calendar
,
"~> 0.16.1"
},
{
:ex_machina
,
"~> 2.0"
,
only:
:test
},
{
:mix_test_watch
,
"~> 0.2"
,
only:
:dev
}]
end
...
...
This diff is collapsed.
Click to expand it.
mix.lock
+
1
−
0
View file @
4cac3854
...
...
@@ -8,6 +8,7 @@
"decimal": {:hex, :decimal, "1.3.1", "157b3cedb2bfcb5359372a7766dd7a41091ad34578296e951f58a946fcab49c6", [:mix], []},
"ecto": {:hex, :ecto, "2.1.4", "d1ba932813ec0e0d9db481ef2c17777f1cefb11fc90fa7c142ff354972dfba7e", [:mix], [{:db_connection, "~> 1.1", [hex: :db_connection, optional: true]}, {:decimal, "~> 1.2", [hex: :decimal, optional: false]}, {:mariaex, "~> 0.8.0", [hex: :mariaex, optional: true]}, {:poison, "~> 2.2 or ~> 3.0", [hex: :poison, optional: true]}, {:poolboy, "~> 1.5", [hex: :poolboy, optional: false]}, {:postgrex, "~> 0.13.0", [hex: :postgrex, optional: true]}, {:sbroker, "~> 1.0", [hex: :sbroker, optional: true]}]},
"elixir_make": {:hex, :elixir_make, "0.4.0", "992f38fabe705bb45821a728f20914c554b276838433349d4f2341f7a687cddf", [:mix], []},
"ex_machina": {:hex, :ex_machina, "2.0.0", "ec284c6f57233729cea9319e083f66e613e82549f78eccdb2059aeba5d0df9f3", [:mix], [{:ecto, "~> 2.1", [hex: :ecto, optional: true]}]},
"fs": {:hex, :fs, "2.12.0", "ad631efacc9a5683c8eaa1b274e24fa64a1b8eb30747e9595b93bec7e492e25e", [:rebar3], []},
"gettext": {:hex, :gettext, "0.13.1", "5e0daf4e7636d771c4c71ad5f3f53ba09a9ae5c250e1ab9c42ba9edccc476263", [:mix], []},
"hackney": {:hex, :hackney, "1.7.1", "e238c52c5df3c3b16ce613d3a51c7220a784d734879b1e231c9babd433ac1cb4", [:rebar3], [{:certifi, "1.0.0", [hex: :certifi, optional: false]}, {:idna, "4.0.0", [hex: :idna, optional: false]}, {:metrics, "1.0.1", [hex: :metrics, optional: false]}, {:mimerl, "1.0.2", [hex: :mimerl, optional: false]}, {:ssl_verify_fun, "1.1.1", [hex: :ssl_verify_fun, optional: false]}]},
...
...
This diff is collapsed.
Click to expand it.
test/support/factory.ex
0 → 100644
+
47
−
0
View file @
4cac3854
defmodule
Pleroma
.
Factory
do
use
ExMachina
.
Ecto
,
repo:
Pleroma
.
Repo
def
user_factory
do
user
=
%
Pleroma
.
User
{
name:
sequence
(
:name
,
&
"Test User
#{
&1
}
"
),
email:
sequence
(
:email
,
&
"user
#{
&1
}
@example.com"
),
nickname:
sequence
(
:nickname
,
&
"nick
#{
&1
}
"
),
password_hash:
Comeonin
.
Pbkdf2
.
hashpwsalt
(
"test"
),
bio:
sequence
(
:bio
,
&
"Tester Number
#{
&1
}
"
),
}
%{
user
|
ap_id:
Pleroma
.
User
.
ap_id
(
user
)
}
end
def
note_factory
do
text
=
sequence
(
:text
,
&
"This is note
#{
&1
}
"
)
user
=
insert
(
:user
)
data
=
%{
"type"
=>
"Note"
,
"content"
=>
text
,
"id"
=>
Pleroma
.
Web
.
ActivityPub
.
ActivityPub
.
generate_object_id
,
"actor"
=>
user
.
ap_id
,
"to"
=>
[
"https://www.w3.org/ns/activitystreams#Public"
],
"published_at"
=>
DateTime
.
utc_now
()
|>
DateTime
.
to_iso8601
}
%
Pleroma
.
Object
{
data:
data
}
end
def
note_activity_factory
do
note
=
insert
(
:note
)
data
=
%{
"id"
=>
Pleroma
.
Web
.
ActivityPub
.
ActivityPub
.
generate_activity_id
,
"actor"
=>
note
.
data
[
"actor"
],
"to"
=>
note
.
data
[
"to"
],
"object"
=>
note
.
data
,
"published_at"
=>
DateTime
.
utc_now
()
|>
DateTime
.
to_iso8601
}
%
Pleroma
.
Activity
{
data:
data
}
end
end
This diff is collapsed.
Click to expand it.
test/test_helper.exs
+
1
−
0
View file @
4cac3854
ExUnit
.
start
()
Ecto
.
Adapters
.
SQL
.
Sandbox
.
mode
(
Pleroma
.
Repo
,
:manual
)
{
:ok
,
_
}
=
Application
.
ensure_all_started
(
:ex_machina
)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment