Page Menu
Home
Sealhub
Search
Configure Global Search
Log In
Files
F969823
setup-test.js
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
setup-test.js
View Options
const
app
=
require
(
"./src/backend/app.js"
);
const
Promise
=
require
(
"bluebird"
);
const
axios
=
require
(
"axios"
);
const
axiosCookieJarSupport
=
require
(
"@3846masa/axios-cookiejar-support"
);
const
tough
=
require
(
"tough-cookie"
);
axiosCookieJarSupport
(
axios
);
const
App
=
app
.
_app
;
const
createCookieJar
=
()
=>
({
jar
:
new
tough
.
CookieJar
(),
withCredentials
:
true
,
});
global
.
TEST_CONFIG
=
{
USERS
:
{
SOME
:
{
CREDENTIALS
:
{
username
:
"some"
,
password
:
"some_password"
,
email
:
"some@example.com"
,
},
SESSION
:
createCookieJar
(),
},
},
};
const
login
=
(
CREDENTIALS
,
SESSION
)
=>
axios
.
post
(
`
${
TEST_CONFIG
.
API_URL
}
/sessions`
,
CREDENTIALS
,
SESSION
);
before
(
async
()
=>
{
App
.
ConfigManager
.
set
(
"datastore_mongo.db_name"
,
"sealious_test"
);
const
serverConfig
=
App
.
ConfigManager
.
get
(
"www-server"
);
TEST_CONFIG
.
API_URL
=
"http://localhost:"
+
serverConfig
.
port
+
serverConfig
[
"api-base"
];
await
app
.
start
();
for
(
let
key
in
TEST_CONFIG
.
USERS
)
{
const
user_data
=
TEST_CONFIG
.
USERS
[
key
].
CREDENTIALS
;
await
App
.
run_action
(
new
App
.
Sealious
.
SuperContext
(),
[
"collections"
,
"users"
],
"create"
,
user_data
);
await
login
(
user_data
,
TEST_CONFIG
.
USERS
[
key
].
SESSION
);
}
});
after
(()
=>
Promise
.
all
(
App
.
ChipManager
.
get_all_collections
().
map
(
collection_name
=>
App
.
Datastore
.
remove
(
collection_name
,
{},
"just_one"
&&
false
)
)
).
then
(()
=>
console
.
log
(
"### Cleared test database"
))
);
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Nov 24, 01:01 (1 d, 12 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
548047
Default Alt Text
setup-test.js (1 KB)
Attached To
Mode
rST sealious-template
Attached
Detach File
Event Timeline
Log In to Comment