2323#include <typedb_driver.h>
2424
2525const char * TYPEDB_CORE_ADDRESS = "127.0.0.1:1729" ;
26+ const char * TYPEDB_CORE_USERNAME = "admin" ;
27+ const char * TYPEDB_CORE_PASSWORD = "password" ;
2628const char * DRIVER_LANG = "c" ;
2729
2830
@@ -40,34 +42,42 @@ bool check_error_may_print(const char* filename, int lineno) {
4042}
4143
4244#define FAILED () check_error_may_print(__FILE__, __LINE__)
45+ TypeDBDriver * driver_open_for_tests (const char * address , const char * username , const char * password ) {
46+ DriverOptions * options = NULL ;
47+ Credentials * creds = credentials_new (username , password );
48+ if (check_error_may_print (__FILE__ , __LINE__ )) goto cleanup ;
49+ options = driver_options_new (false, NULL );;
50+ if (check_error_may_print (__FILE__ , __LINE__ )) goto cleanup ;
51+ TypeDBDriver * driver = driver_open_with_description (address , creds , options , DRIVER_LANG );
52+ cleanup :
53+ driver_options_drop (options );
54+ credentials_drop (creds );
55+
56+ return driver ;
57+ }
4358
4459int main () {
4560 const char databaseName [] = "test_assembly_clib" ;
4661
47- Connection * connection = NULL ;
48- DatabaseManager * databaseManager = NULL ;
62+ TypeDBDriver * driver = NULL ;
4963
5064 bool success = false;
5165
52- connection = driver_open_core (TYPEDB_CORE_ADDRESS , DRIVER_LANG );
53- if (FAILED ()) goto cleanup ;
54-
55- databaseManager = database_manager_new (connection );
66+ driver = driver_open_for_tests (TYPEDB_CORE_ADDRESS , TYPEDB_CORE_USERNAME , TYPEDB_CORE_PASSWORD );
5667 if (FAILED ()) goto cleanup ;
5768
58- databases_create (databaseManager , databaseName );
69+ databases_create (driver , databaseName );
5970 if (FAILED ()) goto cleanup ;
6071
61- if (!databases_contains (databaseManager , databaseName )) {
72+ if (!databases_contains (driver , databaseName )) {
6273 fprintf (stderr , "databases_contains(\'%s\') failed\n" , databaseName );
6374 goto cleanup ;
6475 }
6576
6677 success = true;
6778cleanup :
6879 check_error_may_print (__FILE__ , __LINE__ );
69- database_manager_drop (databaseManager );
70- driver_close (connection );
80+ driver_close (driver );
7181
7282 printf ("Success: %s\n" , success ? "true" : "false" );
7383 return success ? 0 : 1 ;
0 commit comments