In PR #232 we start using static variables for setting up database in this way:
static DBClientConnection* connection = NULL;
if (connection == NULL)
{
/* Set database */
setupDatabase();
connection = getMongoConnection();
}
while most of the *_test.cpp files use:
/* Set database */
setupDatabase();
DBClientConnection* connection = getMongoConnection();
This is @kzangeli comment about this in a later email:
A static variable in a function is like a global variable that is visible in one function only.
The initial assignment of this static variable is made by the compiler, not in runtime.
So, the first time the function is called, connection has the value of NULL.
If its value is changed, that new value will be seen in consequent calls of the function.
Now, this function 'prepareDatabase' can be called several times but 'setupDatabase'
Thus, it seems to be smarter to use static variables for all *_test.cpp using database setup. This issue is about that global change.
Currently, we are using a connection pool to the database (see current implementation of setupDatabase() for unit tests). Is this issue still making sense or should be closed?
In PR #232 we start using static variables for setting up database in this way:
while most of the *_test.cpp files use:
This is @kzangeli comment about this in a later email:
Thus, it seems to be smarter to use static variables for all *_test.cpp using database setup. This issue is about that global change.
Effort: 10 man day