From 131a8b9501362a7b050c594e041a8c2e8dece371 Mon Sep 17 00:00:00 2001 From: Fredric N Date: Mon, 20 Sep 2010 23:06:57 +0200 Subject: [PATCH] Added output test for mysql --- src/output/mysql.c | 5 +---- test/Makefile | 8 +++++++- test/config.ini | 9 +++++++++ test/t_mysql.c | 50 +++++++++++++++++++++++++++++++++++----------- 4 files changed, 55 insertions(+), 17 deletions(-) create mode 100644 test/config.ini diff --git a/src/output/mysql.c b/src/output/mysql.c index ecbc60b..9ce0c29 100644 --- a/src/output/mysql.c +++ b/src/output/mysql.c @@ -1,4 +1,4 @@ -/* arch/mysql.c - Mysql implementation +/* output/mysql.c - Mysql output-driver * * Copyright (C) 2010 Fredric Nilsson * @@ -20,9 +20,6 @@ #include "../common/xalloc.h" #include "../notify/event.h" - -#define STRSZ(s) (sizeof(char) * strlen(s)) - typedef struct { char *host; int port; diff --git a/test/Makefile b/test/Makefile index 472b44a..fe8fe15 100644 --- a/test/Makefile +++ b/test/Makefile @@ -63,7 +63,13 @@ indexer : t_indexer.c -o test_indexer mysql : - $(CC) -D DB_DEBUG $(CFLAGS) $(LDFLAGS) ../src/arch/mysql.c t_mysql.c -o test_mysql + $(CC) -D DB_DEBUG $(CFLAGS) $(LDFLAGS) \ + ../src/output/mysql.c \ + ../src/common/die.c \ + ../src/common/xalloc.c \ + ../src/ini/iniparser.c \ + ../src/ini/dictionary.c \ + t_mysql.c -o test_mysql queue : $(CC) $(CFLAGS) ../src/notify/queue.c t_queue.c -o test_queue diff --git a/test/config.ini b/test/config.ini new file mode 100644 index 0000000..b2a8036 --- /dev/null +++ b/test/config.ini @@ -0,0 +1,9 @@ +[general] +test = mytest ; + +[mysql] +host = localhost ; +username = user ; +password = pw ; +database = development ; +table = filesystem ; diff --git a/test/t_mysql.c b/test/t_mysql.c index a3ed558..83c0ebd 100644 --- a/test/t_mysql.c +++ b/test/t_mysql.c @@ -1,20 +1,46 @@ #include -#include "../src/arch/db.h" +#include +#include +#include +#include + +#include "../src/output/output.h" +#include "../src/ini/iniparser.h" +#include "../src/notify/event.h" + int main(int argc, char *argv[]) { printf("Run!\n"); - - arch_db_init("localhost", "warez", "elebobo", "filesystem", "filesystem"); - - sleep(10); - - arch_db_insert("/this/is/my/path/to/", "myfile", 0); - - arch_db_delete("/this/is/my/path/to/", "myfile"); - - arch_db_close(); + + printf("Here 1\n"); + dictionary *config = iniparser_load("config.ini"); + + printf("Here 2\n"); + notify_event ev; + + printf("Here 3\n"); + ev.path = "/home/kalle/bilder"; + ev.filename = "kalle.jpg"; + ev.type = NOTIFY_CREATE; + + printf("Here 4\n"); + output_init(config); + + printf("Here 5\n"); + int r = output_process(&ev); + + printf("Here 6\n"); + if (r != 0) { + printf("Error:\n"); + printf(output_error(r)); + } + + printf("Here 7\n"); + output_exit(); + + printf("Here 8\n"); return 0; -} +} \ No newline at end of file