Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Added commands test.

  • Loading branch information...
commit 8e4810a4b358a3721c69db7129327fa75f77917a 1 parent c905c51
@banker banker authored
Showing with 44 additions and 0 deletions.
  1. +44 −0 test/commands_test.c
View
44 test/commands_test.c
@@ -0,0 +1,44 @@
+/* commands_test.c */
+
+#include "test.h"
+#include "mongo.h"
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+
+int main() {
+ mongo conn[1];
+ bson cmd[1];
+ bson out[1];
+ bson_iterator it[1];
+
+ const char *db = "test";
+ const char *col = "c.capped";
+
+ INIT_SOCKETS_FOR_WINDOWS;
+
+ if ( mongo_connect( conn , TEST_SERVER , 27017 ) ) {
+ printf( "failed to connect\n" );
+ exit( 1 );
+ }
+
+ mongo_cmd_drop_collection( conn, db, col, NULL );
+
+ ASSERT( mongo_create_capped_collection( conn, db, col,
+ 1024, 100, NULL ) == MONGO_OK );
+
+ bson_init( cmd );
+ bson_append_string( cmd, "collstats", col );
+ bson_finish( cmd );
+
+ ASSERT( mongo_run_command( conn, db, cmd, out ) == MONGO_OK );
+
+ ASSERT( bson_find( it, out, "capped" ) == BSON_INT );
+ ASSERT( bson_find( it, out, "max" ) == BSON_INT );
+
+ mongo_cmd_drop_collection( conn, "test", col, NULL );
+ mongo_cmd_drop_db( conn, db );
+
+ mongo_destroy( conn );
+ return 0;
+}

0 comments on commit 8e4810a

Please sign in to comment.
Something went wrong with that request. Please try again.