8 #include <CUnit/CUnit.h>
29 LOG_FATAL(
"Unable to connect to database");
32 MagicCookie = magic_open(MAGIC_PRESERVE_ATIME|MAGIC_MIME);
60 char SQL[MAXCMD] = {0};
61 PGresult *result = NULL;
62 char mimetype_name[] =
"application/octet-stream";
64 memset(
SQL,
'\0', MAXCMD);
65 snprintf(
SQL, MAXCMD,
"DELETE FROM mimetype where mimetype_name = '%s';", mimetype_name);
74 memset(
SQL,
'\0', MAXCMD);
75 snprintf(
SQL, MAXCMD,
"INSERT INTO mimetype (mimetype_name) VALUES ('%s');", mimetype_name);
87 memset(
SQL,
'\0', MAXCMD);
88 snprintf(
SQL, MAXCMD,
"SELECT mimetype_name from mimetype where mimetype_name = ('%s');", mimetype_name);
95 int mimetype_id = atoi(PQgetvalue(result, 0, 0));
98 CU_ASSERT_NOT_EQUAL(ret, mimetype_id);
101 memset(
SQL,
'\0', MAXCMD);
102 snprintf(
SQL, MAXCMD,
"DELETE FROM mimetype where mimetype_name = '%s';", mimetype_name);
115 memset(
SQL,
'\0', MAXCMD);
116 snprintf(
SQL, MAXCMD,
"SELECT mimetype_name from mimetype where mimetype_name = ('%s');", mimetype_name);
124 mimetype_id = atoi(PQgetvalue(result, 0, 0));
127 CU_ASSERT_NOT_EQUAL(ret, mimetype_id);
129 memset(
SQL,
'\0', MAXCMD);
130 snprintf(
SQL, MAXCMD,
"DELETE FROM mimetype where mimetype_name = '%s';", mimetype_name);
char SQL[256]
SQL query to execute.
PGconn * pgConn
Database connection.
int DBFindMime(char *Mimetype)
Find a mime type in the DBMime table.
magic_t MagicCookie
for Magic
PGresult * DBMime
contents of mimetype table
PGconn * fo_dbconnect(char *DBConfFile, char **ErrorBuf)
Connect to a database. The default is Db.conf.
int fo_checkPQresult(PGconn *pgConn, PGresult *result, char *sql, char *FileID, int LineNumb)
Check the result status of a postgres SELECT.
int fo_checkPQcommand(PGconn *pgConn, PGresult *result, char *sql, char *FileID, int LineNumb)
Check the result status of a postgres commands (not select) If an error occured, write the error to s...
CU_TestInfo testcases_DBFindMime[]
testcases for function DBFindMime
int DBFindMimeInit()
initialize
int DBFindMimeClean()
clean the env
void testDBFindMime()
for function DBFindMime()
char * DBConfFile
DB conf file location.