Skip to content
Snippets Groups Projects
Commit 3c01bf1d authored by Fredrik Noring's avatar Fredrik Noring
Browse files

Added an optional database checker.

Rev: lib/modules/Yabu.pmod/test.pike:1.4
parent eac9f540
No related branches found
No related tags found
No related merge requests found
...@@ -4,6 +4,21 @@ ...@@ -4,6 +4,21 @@
int main(int argc, array argv) int main(int argc, array argv)
{ {
if(argc == 3 && argv[1] == "dbck") {
string filename = argv[2];
object db = .module.db(filename, "r");
werror("Database data: ");
foreach(indices(db), string table) {
object table = db[table];
foreach(indices(table), string row)
werror("%O", table[row]);
}
werror("\nThe database %O seems to be intact.\n", filename);
return 0;
}
.module.db("test.db", "wct")->purge(); .module.db("test.db", "wct")->purge();
object db = .module.db("test.db", "wct"); object db = .module.db("test.db", "wct");
object table = db["Aces"]; object table = db["Aces"];
...@@ -18,7 +33,7 @@ int main(int argc, array argv) ...@@ -18,7 +33,7 @@ int main(int argc, array argv)
ERR("Table diff #2!"); ERR("Table diff #2!");
transaction["Buck"] = "Rogers"; transaction["Buck"] = "Rogers";
if(!equal(indices(table), ({ "Blixt" }))) if(!equal(indices(table), ({ "Blixt" })))
ERR("Table diff #3!"); ERR("Table diff #3!");
if(!equal(sort(indices(transaction)), ({ "Blixt", "Buck" }))) if(!equal(sort(indices(transaction)), ({ "Blixt", "Buck" })))
...@@ -31,7 +46,7 @@ int main(int argc, array argv) ...@@ -31,7 +46,7 @@ int main(int argc, array argv)
ERR("Table diff #7!"); ERR("Table diff #7!");
if(transaction["Blixt"] != "Gordon") if(transaction["Blixt"] != "Gordon")
ERR("Table diff #8!"); ERR("Table diff #8!");
transaction->commit(); transaction->commit();
if(table["Buck"] != "Rogers") if(table["Buck"] != "Rogers")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment