class TestCase::Online {
  use Fn;
  use Go;
  use Array;
  
  use Mojo::Transaction;
  use Mojo::Transaction::HTTP;
  use Mojo::Content::Single;
  
  use Mojo::UserAgent;
  
  our $RESULT : IntList;
  
  static method test_http_tiny : int () {
    
    my $url = "http://google.com";
    
    my $ua = Mojo::UserAgent->new;
    
    my $res = $ua->get($url)->result;
    
    my $body = $res->body;
    
    unless (Fn->contains($body, "www.google.com")) {
      return 0;
    }
    
    unless ($res->code == 200 || $res->code == 301) {
      return 0;
    }
    
    return 1;
  }
  
  static method go_http_tiny : int () {
    
    $RESULT = IntList->new;
    
    Go->go(method : void () {
      my $url = "http://google.com";
      
      my $ua = Mojo::UserAgent->new;
      
      my $res = $ua->get($url)->result;
      
      my $body = $res->body;
      
      $RESULT->push(Fn->contains($body, "www.google.com"));
    });
    
    Go->go(method : void () {
      my $url = "http://google.com";
      
      my $ua = Mojo::UserAgent->new;
      
      my $res = $ua->get($url)->result;
      
      my $body = $res->body;
      
      $RESULT->push(Fn->contains($body, "www.google.com"));
    });
    
    Go->gosched;
    
    unless (Array->equals_int($RESULT->to_array, [1, 1])) {
      return 0;
    }
    
    $RESULT = undef;
    
    return 1;
  }
}
