support testing on remote server
This commit is contained in:
Родитель
8903dd3753
Коммит
5e282b7a29
11
SConstruct
11
SConstruct
|
@ -1,5 +1,15 @@
|
|||
# -*- mode: python; -*-
|
||||
|
||||
|
||||
# --- options ----
|
||||
AddOption('--test-server',
|
||||
dest='test_server',
|
||||
default='127.0.0.1',
|
||||
type='string',
|
||||
nargs=1,
|
||||
action='store',
|
||||
help='IP address of server to use for testing')
|
||||
|
||||
import os
|
||||
import sys
|
||||
|
||||
|
@ -25,6 +35,7 @@ env.Default( env.Alias( "lib" , [ m[0] , b[0] ] ) )
|
|||
testEnv = env.Clone()
|
||||
testEnv.Append( LIBS=["json"] )
|
||||
testEnv.Append( LIBS=["mongoc","bson"] )
|
||||
testEnv.Append( CFLAGS=['-DTEST_SERVER=\\"%s\\"'%GetOption('test_server')] )
|
||||
testEnv.Prepend( LIBPATH=["."] )
|
||||
|
||||
testCoreFiles = [ "test/md5.c" ]
|
||||
|
|
|
@ -70,17 +70,14 @@ mongo_message * mongo_message_create( int len , int id , int responseTo , int op
|
|||
|
||||
int mongo_connect( mongo_connection * conn , mongo_connection_options * options ){
|
||||
int x = 1;
|
||||
conn->options.port = 27017;
|
||||
conn->connected = 0;
|
||||
|
||||
if ( options ){
|
||||
memcpy( &(conn->options) , options , sizeof( mongo_connection_options ) );
|
||||
printf( "can't handle options to mongo_connect yet" );
|
||||
exit(-2);
|
||||
return -2;
|
||||
}
|
||||
else {
|
||||
strcpy( conn->options.host , "127.0.0.1" );
|
||||
conn->options.port = 27017;
|
||||
}
|
||||
|
||||
/* setup */
|
||||
|
|
|
@ -2,9 +2,11 @@
|
|||
|
||||
#include "mongo.h"
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
int main(){
|
||||
mongo_connection conn;
|
||||
mongo_connection_options opts;
|
||||
bson_buffer bb;
|
||||
bson b;
|
||||
|
||||
|
@ -12,7 +14,11 @@ int main(){
|
|||
bson_append_double( &bb , "a" , 17 );
|
||||
bson_init( &b , bson_finish( &bb ) , 1 );
|
||||
|
||||
mongo_exit_on_error( mongo_connect( &conn , 0 ) );
|
||||
strncpy(opts.host, TEST_SERVER, 255);
|
||||
opts.host[254] = '\0';
|
||||
opts.port = 27017;
|
||||
|
||||
mongo_exit_on_error( mongo_connect( &conn , &opts ) );
|
||||
mongo_exit_on_error( mongo_insert( &conn , "test.cc" , &b ) );
|
||||
|
||||
mongo_query( &conn , "test.cc" , &b , 0 , 0 , 0 , 0 );
|
||||
|
|
Загрузка…
Ссылка в новой задаче