forked from github/server
fix type conversion and incomplete database test.
This commit is contained in:
parent
32009b7043
commit
da3270517a
2 changed files with 8 additions and 4 deletions
|
@ -50,6 +50,7 @@ static void test_update_faction(CuTest *tc) {
|
||||||
int uid;
|
int uid;
|
||||||
|
|
||||||
test_setup();
|
test_setup();
|
||||||
|
db_driver_open(DB_GAME, NULL);
|
||||||
f = test_create_faction(NULL);
|
f = test_create_faction(NULL);
|
||||||
uid = db_driver_faction_save(f->uid, f->no, 0,
|
uid = db_driver_faction_save(f->uid, f->no, 0,
|
||||||
faction_getemail(f),
|
faction_getemail(f),
|
||||||
|
@ -59,6 +60,7 @@ static void test_update_faction(CuTest *tc) {
|
||||||
faction_getemail(f),
|
faction_getemail(f),
|
||||||
faction_getpassword(f));
|
faction_getpassword(f));
|
||||||
CuAssertIntEquals(tc, f->uid, uid);
|
CuAssertIntEquals(tc, f->uid, uid);
|
||||||
|
db_driver_close(DB_GAME);
|
||||||
test_teardown();
|
test_teardown();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -100,9 +100,7 @@ dbrow_id db_driver_faction_save(dbrow_id id, int no, int turn, const char *email
|
||||||
sqlite3_int64 row_id;
|
sqlite3_int64 row_id;
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
if (!g_game_db) {
|
assert(g_game_db);
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
if (id != 0) {
|
if (id != 0) {
|
||||||
int rows;
|
int rows;
|
||||||
|
|
||||||
|
@ -193,6 +191,10 @@ int db_driver_open(database_t db, const char *dbname)
|
||||||
{
|
{
|
||||||
ERRNO_CHECK();
|
ERRNO_CHECK();
|
||||||
|
|
||||||
|
if (!dbname) {
|
||||||
|
/* by default, use an in-memory database */
|
||||||
|
dbname = ":memory:";
|
||||||
|
}
|
||||||
if (db == DB_SWAP) {
|
if (db == DB_SWAP) {
|
||||||
g_swapname = dbname;
|
g_swapname = dbname;
|
||||||
return db_open_swap(dbname);
|
return db_open_swap(dbname);
|
||||||
|
|
Loading…
Reference in a new issue