### ----------------------------------------------------
### -- MongoDB
### -- Licenses: Artistic-2.0
### -- Authors: Marcel Timmerman, Paweł Pabian
### -- File: xt/Tests/IPv6/100-connect.rakutest
### ----------------------------------------------------
use v6;
use lib 't', 'lib';
use Test;

#use Test-support;

use MongoDB;
use MongoDB::Client;
use MongoDB::Database;
#use MongoDB::Server::Control;
#use MongoDB::MDBConfig;

use BSON::Document;

#-------------------------------------------------------------------------------
my Str $log-path = @*ARGS[0];
my Version $version .= new(@*ARGS[1]);
my @server-ports = @*ARGS[2..*];
note "args: $log-path, $version, @server-ports";

#-------------------------------------------------------------------------------
drop-send-to('mongodb');
drop-send-to('screen');
#modify-send-to( 'screen', :level(MongoDB::MdbLoglevels::Trace));
my $handle = $log-path.IO.open( :mode<wo>, :append);
add-send-to( 'mdb', :to($handle), :min-level(MongoDB::MdbLoglevels::Trace));
#set-filter(|<ObserverEmitter Timer Socket>);

#info-message("Test $?FILE start");

my BSON::Document $req;
my BSON::Document $doc;

my Str $uri = "mongodb://[::1]:@server-ports[0]/";
my MongoDB::Client $client .= new(:$uri);
my MongoDB::Database $database = $client.database('test');
my MongoDB::Database $db-admin = $client.database('admin');

#-------------------------------------------------------------------------------
subtest "ipv6 connect", {

  ## get version to skip certain tests
  #my Str $version = $ts.server-version($database);
  #note $version;

  # Drop database first then create new databases
  $req .= new: ( dropDatabase => 1 );
  $doc = $database.run-command($req);

  note $doc.perl;
}

#-------------------------------------------------------------------------------
info-message("Test $?FILE stop");
done-testing();


