4449c39e859d6c7ed75f458a7caf61ed33cf7364
[idzebra-moved-to-github.git] / test / api / t14.c
1 /* This file is part of the Zebra server.
2    Copyright (C) 1995-2008 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 #include "testlib.h"
21
22 static void create_search_drop(ZebraHandle zh)
23 {
24     const char *rec = "<gils><title>some</title></gils>";
25     const char *opaque_id = "9";
26
27     YAZ_CHECK(zebra_create_database (zh, "Default") == ZEBRA_OK);
28
29     /* bug #447 */
30     YAZ_CHECK(zebra_update_record(
31                   zh, action_update,
32                   0 /* record type */,
33                   0 /* sysno */,
34                   opaque_id,
35                   0 /* fname */,
36                   rec, strlen(rec))
37               == ZEBRA_OK); /* insert really */
38     
39     YAZ_CHECK(zebra_update_record(
40                   zh, action_update,
41                   0 /* record type */,
42                   0 /* sysno */,
43                   opaque_id,
44                   0 /* fname */,
45                   rec, strlen(rec))
46               == ZEBRA_OK); /* replace really */
47     
48     YAZ_CHECK(tl_query(zh, "@attr 1=4 some", 1));
49
50     zebra_drop_database(zh, "Default");
51
52     YAZ_CHECK(tl_query_x(zh, "@attr 1=4 some", 0, 109));
53
54 }
55
56 static void tst(int argc, char **argv)
57 {
58     ZebraService zs = tl_start_up("zebra.cfg", argc, argv);
59     ZebraHandle zh = zebra_open(zs, 0);
60
61     YAZ_CHECK(zebra_select_database(zh, "Default") == ZEBRA_OK);
62
63     zebra_init(zh);
64
65     create_search_drop(zh);
66     /* bug #447 */
67     create_search_drop(zh);
68
69     YAZ_CHECK(tl_close_down(zh, zs));
70 }
71
72 TL_MAIN
73 /*
74  * Local variables:
75  * c-basic-offset: 4
76  * indent-tabs-mode: nil
77  * End:
78  * vim: shiftwidth=4 tabstop=8 expandtab
79  */
80