You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
log.debug(`Checking if ${id} is a member of ${group}.`);
if(
config.adminUsers&&
group==='admins'&&
isString(id)&&
orcidUtils.isValid(id)
){
return(
config.adminUsers.includes(id)||
(awaitgroups.isMemberOf('admins',id))
);
}else{
returngroups.isMemberOf(group,id);
}
};
This module contains all sorts of things not used (e.g. command-line options), but the main problem is that it reads from the environment/.env file and doesn't allow it to be changed programmatically, making testing impossible (refs #388, #400 (comment)).
Configuration needs to be changed so that it's passed in from the outside, allow tests to set it as needed.
The text was updated successfully, but these errors were encountered:
This change adds a test case for when a preprint cannot be found.
The test case is straightforward but requires changes to be able to support it. As there's a strong coupling between the code and the ORM (e.g. through `getFields`), we can't replace the repositories with in-memory versions. Worse, some of the code requires Postgres SQL, rather than the generic type we can use across different databases.
As a result, we have to try and use an actual Postgres instance. Doing so makes the tests slower and harder to develop. (Docker solves the problem for CI, but Jest tests should be isolated enough that they can be run locally, such as in the developer's IDE.)
To try and reduce the complexity, this uses pg-mem (https://github.com/oguimbal/pg-mem), an in-memory emulation of Postgres. I've not used this before, and the readme clearly labels it as experimental, but it's worked for what I've tried so far. It has a nice rollback feature, which allows resetting the database before each test. There's probably going to be pitfuls, but it seems to be worth continuing.
I had to change the codebase to allow passing in pg-mem's customised MikroORM. Unfortunately, there isn't a clean separation between the ORM and its database connection; I'd be much happier just passing in the latter to the app, but this will have to do for now.
Refs #388, #391, #419
Background configuration is read by a single module and is then directly used by various places in the codebase, such as
prereview/src/backend/middleware/auth.js
Lines 41 to 56 in d542241
This module contains all sorts of things not used (e.g. command-line options), but the main problem is that it reads from the environment/.env file and doesn't allow it to be changed programmatically, making testing impossible (refs #388, #400 (comment)).
Configuration needs to be changed so that it's passed in from the outside, allow tests to set it as needed.
The text was updated successfully, but these errors were encountered: