blob: 7e3a7a73d5a381d2b586db7f08d50f2a711f282a [file] [log] [blame]
<!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>