summaryrefslogtreecommitdiff
path: root/share/www/verify_install.html
blob: 388833bd91a7c272bb1ac3a71fb3d1f4e952e901 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
<!DOCTYPE html>
<!--

Licensed under the Apache License, Version 2.0 (the "License"); you may not use
this file except in compliance with the License. You may obtain a copy of the
License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed
under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
CONDITIONS OF ANY KIND, either express or implied. See the License for the
specific language governing permissions and limitations under the License.

-->
<html lang="en">
  <head>
    <title>Test Suite</title>
    <meta http-equiv="Content-Type" content="text/html;charset=utf-8">
    <link rel="stylesheet" href="style/layout.css?0.11.0" type="text/css">
    <script src="script/json2.js"></script>
    <script src="script/sha1.js"></script>
    <script src="script/jquery.js"></script>
    <script src="script/jquery.couch.js"></script>
    <script src="script/jquery.dialog.js"></script>
    <script src="script/futon.js"></script>
    <script src="script/couch.js"></script>
    <script src="script/couch_test_runner.js"></script>
    <script>
    $(function($) {
      $("#result").html("");
      $("#run").click(verify_install);
    });

    function T(arg, desc) {
      if(!arg) {
        mesg = "Assertion failed" + (desc ? ": " + desc : "");
        throw new Error(mesg);
      }
    }

    function TEquals(expect, found, descr) {
      var mesg = "expected '" + expect + "', got '" + found + "' " + descr;
      T(expect === found, mesg);
    }

    function tests() {
      CouchDB.urlPrefix = "..";
      var db = new CouchDB("test_suite_db", {"X-Couch-Full-Commit":"false"});

      // cleanup, ignore the 404
      try {db.deleteDb();} catch(e) {};
      // create db
      db.createDb();

      // create document
      var doc = {a:1};
      var resp = db.save(doc);
      TEquals(true, resp.ok, "save document");
      // update document
      doc.b = 2;
      resp = db.save(doc);
      TEquals(true, resp.ok, "update document");
      TEquals(2, doc.b, "update document verified");
      // delete document
      resp = db.deleteDoc(doc);
      TEquals(true, resp.ok, "delete document");
      var doc2 = db.open(doc.id);
      TEquals(doc2, null, "delete document verified");

      // excercise query server
      db.save({a:1});
      db.save({a:2});
      db.save({a:3});

      //  temporary view
      var resp = db.query(function(doc) {
        if(doc.a) {
          emit(doc.a, doc.a);
        }
      });
      TEquals(3, resp.total_rows, "temp view query");

      // replication
      //   create second db
      var db2 = new CouchDB("test_suite_db2", {"X-Couch-Full-Commit":"false"});
      try {db2.deleteDb();} catch (e) {};
      db2.createDb();
      //   do replicate
      CouchDB.replicate("test_suite_db", "test_suite_db2");
      //   compare results
      TEquals(db.info().doc_count, db2.info().doc_count, "databases are equal");
    }

    function verify_install() {
      try {
        var result = $("#result");
        result.html("Running…");
        tests();
        result.html("√ Your installation looks fine. Time to Relax.");
      } catch(e) {
        console.log(e);
        result.html("X: " + e);
      }
    }
    </script>
  </head>
  <body><div id="wrap">
    <h1>
      <a href="index.html">Overview</a>
      <strong>Verify Install</strong>
    </h1>
    <div id="content">
      <ul id="toolbar">
        <li><button class="run" id="run">Verify Your Installation.</button><span id="result"></span></li>
      </ul>
    </div>
  </div></body>
</html>