/* Copyright (c) 2017-2018 Dovecot authors, see the included COPYING file */
#include "lib.h"
#include "test-lib.h"
#include "sql-api.h"
#include "dict.h"
#include "dict-private.h"
#include "dict-sql.h"
#include "dict-sql-private.h"
#include "driver-test.h"
{
.username = "testuser",
.base_dir = "."
};
}
{
dict_deinit(&dict);
}
}
const struct test_driver_result *result)
{
}
static void test_lookup_one(void)
{
.rows = 1,
.cols = 1,
};
.nqueries = 1,
};
test_begin("dict lookup one");
test_setup(&dict);
test_end();
}
static void test_atomic_inc(void)
{
const char *error;
.nqueries = 2,
.queries = (const char *[]){
"UPDATE counters SET value=value+128 WHERE class = 'global' AND name = 'counter'",
"UPDATE quota SET bytes=bytes+128,count=count+1 WHERE username = 'testuser'",
NULL},
};
test_begin("dict atomic inc");
test_setup(&dict);
test_end();
}
static void test_set(void)
{
const char *error;
.affected_rows = 1,
.nqueries = 2,
.queries = (const char *[]){
"INSERT INTO counters (value,class,name) VALUES (128,'global','counter') ON DUPLICATE KEY UPDATE value=128",
"INSERT INTO quota (bytes,count,username) VALUES (128,1,'testuser') ON DUPLICATE KEY UPDATE bytes=128,count=1",
NULL},
};
test_begin("dict set");
test_setup(&dict);
test_end();
}
static void test_unset(void)
{
const char *error;
.affected_rows = 1,
.nqueries = 3,
.queries = (const char *[]){
"DELETE FROM counters WHERE class = 'global' AND name = 'counter'",
"DELETE FROM quota WHERE username = 'testuser'",
"DELETE FROM quota WHERE username = 'testuser'",
NULL},
};
test_begin("dict unset");
test_setup(&dict);
test_end();
}
static void test_iterate(void)
{
.rows = 5,
.cols = 2,
.row_data = (const char **[]){
},
};
.nqueries = 1,
.queries = (const char *[]){
"SELECT value,name FROM counters WHERE class = 'global' AND name = 'counter'",
NULL},
};
test_begin("dict iterate");
test_setup(&dict);
idx++;
}
"SELECT value,name FROM counters WHERE class = 'global' AND name LIKE '%' AND name NOT LIKE '%/%'",
};
idx = 0;
idx++;
}
test_end();
}
int main(void) {
static void (*const test_functions[])(void) = {
};
return ret;
}