File: setserver.t

package info (click to toggle)
libsphinx-search-perl 1%3A0.31-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster
  • size: 220 kB
  • sloc: perl: 2,004; makefile: 2
file content (45 lines) | stat: -rw-r--r-- 883 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#! /usr/bin/perl


use Test::More;
use strict;
use warnings;
use Socket;

use Sphinx::Search;

use lib qw(t/testlib testlib);
use TestDB;



my $testdb = TestDB->new();

if (my $msg = $testdb->preflight) {
    plan skip_all => $msg;
}

unless ($testdb->run_searchd()) {
    plan skip_all => "Failed to run searchd; skipping tests.";
}

plan tests => 5;


my $sphinx = Sphinx::Search->new({ port => $testdb->searchd_port });
ok($sphinx, "Constructor");

my $e;

$sphinx->SetServer('', $testdb->searchd_port); 
$e = $sphinx->Query('a');
ok(! $e, "Error on empty server");
like($sphinx->GetLastError(), qr/Failed to open connection|Bad arg length/);

$sphinx->Query('a');
$sphinx->SetServer('my.nosuchhost.exists', $testdb->searchd_port);
$e = $sphinx->Query('a');
ok(! $e, "Error on non-existent server");
like($sphinx->GetLastError(), qr/Failed to open connection|Bad arg length/);