ee9abaa871e4d37c49866ad6590c23571a343552
[idzebra-moved-to-github.git] / test / api / test_update_record.c
1 /* This file is part of the Zebra server.
2    Copyright (C) 2004-2013 Index Data
3
4 Zebra is free software; you can redistribute it and/or modify it under
5 the terms of the GNU General Public License as published by the Free
6 Software Foundation; either version 2, or (at your option) any later
7 version.
8
9 Zebra is distributed in the hope that it will be useful, but WITHOUT ANY
10 WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
12 for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
17
18 */
19
20 #if HAVE_CONFIG_H
21 #include <config.h>
22 #endif
23 #include "testlib.h"
24
25 static void create_search_drop(ZebraHandle zh)
26 {
27     const char *rec = "<gils><title>some</title></gils>";
28     const char *opaque_id = "9";
29
30     YAZ_CHECK(zebra_create_database (zh, "Default") == ZEBRA_OK);
31
32     /* bug #447 */
33     YAZ_CHECK(zebra_update_record(
34                   zh, action_update,
35                   0 /* record type */,
36                   0 /* sysno */,
37                   opaque_id,
38                   0 /* fname */,
39                   rec, strlen(rec))
40               == ZEBRA_OK); /* insert really */
41
42     YAZ_CHECK(zebra_update_record(
43                   zh, action_update,
44                   0 /* record type */,
45                   0 /* sysno */,
46                   opaque_id,
47                   0 /* fname */,
48                   rec, strlen(rec))
49               == ZEBRA_OK); /* replace really */
50
51     YAZ_CHECK(tl_query(zh, "@attr 1=4 some", 1));
52
53     zebra_drop_database(zh, "Default");
54
55     YAZ_CHECK(tl_query_x(zh, "@attr 1=4 some", 0, 109));
56
57 }
58
59 static void tst(int argc, char **argv)
60 {
61     ZebraService zs = tl_start_up("zebra.cfg", argc, argv);
62     ZebraHandle zh = zebra_open(zs, 0);
63
64     YAZ_CHECK(zebra_select_database(zh, "Default") == ZEBRA_OK);
65
66     zebra_init(zh);
67
68     create_search_drop(zh);
69     /* bug #447 */
70     create_search_drop(zh);
71
72     YAZ_CHECK(tl_close_down(zh, zs));
73 }
74
75 TL_MAIN
76 /*
77  * Local variables:
78  * c-basic-offset: 4
79  * c-file-style: "Stroustrup"
80  * indent-tabs-mode: nil
81  * End:
82  * vim: shiftwidth=4 tabstop=8 expandtab
83  */
84