Makefile.PL: declare explicit Time::HiRes dependency
[perl-MogileFS-Client.git] / t / 10-basics.t
blob84ad99b98f2de9c11a3eee2a4f922fc8e4bc4238
1 #!/usr/bin/perl -w
3 use strict;
4 use Test::More;
5 use MogileFS::Client;
6 use MogileFS::Admin;
8 my $moga = MogileFS::Admin->new(hosts => ['127.0.0.1:7001']);
9 my $doms = eval { $moga->get_domains };
11 unless ($doms) {
12 plan skip_all => "No mogilefsd process running on 127.0.0.1:7001";
13 exit 0;
14 } else {
15 plan tests => 10;
18 my $test_ns = "_MogileFS::Client::TestSuite";
20 if ($doms->{$test_ns}) {
21 pass("test namespace already exists");
22 } else {
23 ok($moga->create_domain($test_ns), "created test namespace");
26 my $mogc = MogileFS::Client->new(hosts => ['127.0.0.1:7001'],
27 domain => $test_ns);
28 ok($mogc, "made mogile client object");
30 # bogus class..
31 my $fh = $mogc->new_file("test_file1", "bogus_class");
32 ok(! $fh, "got a filehandle");
33 is($mogc->errcode, "unreg_class", "got correct error about making file in bogus class");
35 $fh = $mogc->new_file("test_file1");
36 ok($fh, "filehandle in general class");
38 my $data = "0123456789" x 500;
39 my $wv = (print $fh $data);
40 is($wv, length $data, "wrote data bytes out");
41 ok($fh->close, "closed successfully");
43 ok(scalar $mogc->get_paths("test_file1") >= 1, "exists in one or more places");
45 ok($mogc->delete("test_file1"), "deleted test file");
47 ok($moga->delete_domain($test_ns), "deleted test namespace");
49 #use Data::Dumper;
50 #print Dumper($doms);