RPM Community Forums

Mailing List Message of <rpm-cvs>

[CVS] RPM: rpm-5_3: rpm/tests/mongo/ Makefile.am tutorial.js

From: Jeff Johnson <jbj@rpm5.org>
Date: Thu 23 Sep 2010 - 21:44:59 CEST
Message-Id: <20100923194459.5BF84D4634@rpm5.org>
  RPM Package Manager, CVS Repository
  /cvs/
  ____________________________________________________________________________

  Server: rpm5.org                         Name:   Jeff Johnson
  Root:   /v/rpm/cvs                       Email:  jbj@rpm5.org
  Module: rpm                              Date:   23-Sep-2010 21:44:59
  Branch: rpm-5_3                          Handle: 2010092319445800

  Added files:              (Branch: rpm-5_3)
    rpm/tests/mongo         tutorial.js
  Modified files:           (Branch: rpm-5_3)
    rpm/tests/mongo         Makefile.am

  Log:
    - tests: simple tutorial tests using the mongo shell.

  Summary:
    Revision    Changes     Path
    1.3.2.3     +7  -2      rpm/tests/mongo/Makefile.am
    1.1.2.1     +88 -0      rpm/tests/mongo/tutorial.js
  ____________________________________________________________________________

  patch -p0 <<'@@ .'
  Index: rpm/tests/mongo/Makefile.am
  ============================================================================
  $ cvs diff -u -r1.3.2.2 -r1.3.2.3 Makefile.am
  --- rpm/tests/mongo/Makefile.am	18 Sep 2010 18:03:30 -0000	1.3.2.2
  +++ rpm/tests/mongo/Makefile.am	23 Sep 2010 19:44:58 -0000	1.3.2.3
  @@ -2,7 +2,7 @@
   
   AUTOMAKE_OPTIONS = 1.4 foreign
   
  -EXTRA_DIST =
  +EXTRA_DIST =	tutorial.js
   
   EXTRA_PROGRAMS = \
   	endian_swap \
  @@ -40,6 +40,7 @@
   #	$(top_builddir)/lib/librpm.la \
   #	$(RPMDB_LDADD)
   
  +mongo =			@__MONGO@
   mongoserver =		198.178.231.189		# XXX mongo.rpm5.org
   
   all_types_SOURCES =	all_types.c
  @@ -78,7 +79,11 @@
   update_SOURCES =	update.c
   update_LDADD =		$(RPMIO_LDADD)
   
  -check-local:
  +check-shell:
  +	@echo "=== mongo-shell ==="
  +	@-${mongo} ${mongoserver} < tutorial.js
  +
  +check-local:	check-shell
   	@echo "=== mongo-c-driver ==="
   	@echo "--> all_types"
   	@-./all_types
  @@ .
  patch -p0 <<'@@ .'
  Index: rpm/tests/mongo/tutorial.js
  ============================================================================
  $ cvs diff -u -r0 -r1.1.2.1 tutorial.js
  --- /dev/null	2010-09-23 21:44:00.000000000 +0200
  +++ tutorial.js	2010-09-23 21:44:59.283009965 +0200
  @@ -0,0 +1,88 @@
  +use mydb;
  +
  +// --- special command helpers
  +help;
  +db.help();
  +show dbs;
  +show collections;
  +show users;
  +show profile;
  +
  +// --- basic shell JS operations
  +db;
  +db.auth('foo', 'bar');
  +
  +db.things.help();
  +things = db.things;
  +
  +bing = { N : "bing" };
  +bang = { N : "bang" };
  +boom = { N : "boom" };
  +things.find();
  +
  +things.remove(bing);
  +things.find();
  +
  +things.save(bing);
  +things.remove(bing);
  +things.find();
  +
  +things.insert(bing);
  +things.insert(bang);
  +things.insert(boom);
  +things.ensureIndex( { N: 1 } );
  +things.remove(bang);
  +things.find();
  +
  +things.update(bing, bang, false, false);
  +things.find();
  +things.update(bang, bing, true, false);
  +things.find();
  +things.insert(bang);
  +things.insert(bang);
  +// things.update(bang, bing, true, true);
  +things.find();
  +
  +// --- cleanup
  +things.drop();
  +
  +db.getSisterDB('test').getCollectionNames();
  +
  +
  +// --- tutorial
  +j = { name : "mongo" };
  +t = { x : 3 };
  +things.save(j);
  +things.save(t);
  +things.find();
  +
  +for (var i = 1; i <= 20; i++) things.save({x : 4, j : i});
  +things.find();
  +
  +var cursor = things.find();
  +while (cursor.hasNext()) printjson(cursor.next());
  +
  +things.find().forEach(printjson);
  +
  +var cursor = things.find();
  +printjson(cursor[4]);
  +
  +var arr = things.find().toArray();
  +arr[5];
  +
  +things.find({name:"mongo"}).forEach(printjson);
  +
  +things.find({x:4}).forEach(printjson);
  +
  +things.find({x:4}, {j:true}).forEach(printjson);
  +
  +printjson(things.findOne({name:"mongo"}));
  +
  +things.find().limit(3);
  +
  +printjson;
  +
  +// --- cleanup
  +things.drop();
  +
  +exit;
  @@ .
Received on Thu Sep 23 21:44:59 2010
Driven by Jeff Johnson and the RPM project team.
Hosted by OpenPKG and Ralf S. Engelschall.
Powered by FreeBSD and OpenPKG.