]> iEval git - webservice-scaleway.git/blame_incremental - t/real.t
Bump version and update Changes
[webservice-scaleway.git] / t / real.t
... / ...
CommitLineData
1#!/usr/bin/perl
2use strict;
3use warnings;
4
5use WebService::Scaleway;
6
7use Test::More;
8
9BEGIN {
10 plan skip_all => 't/api_key file missing' unless -f 't/api_key';
11 plan tests => 7;
12}
13
14open my $akf, '<', 't/api_key';
15my $token = <$akf>;
16chomp $token;
17close $akf;
18my $sw = WebService::Scaleway->new($token);
19
20my $org = $sw->organizations;
21my $user = $sw->user($org->users->[0]->{id});
22note 'This token belongs to ', $user->fullname, ' <', $user->email, '>';
23
24my $ip = $sw->create_ip($org);
25note "Created new ip $ip with address ", $ip->address;
26is $sw->ip($ip)->address, $ip->address, 'get_ip';
27my @ips = $sw->ips;
28ok grep ({$_->address eq $ip->address} @ips), 'list_ips';
29
30my $vol = $sw->create_volume('testvol', $org, 'l_ssd', 50_000_000_000);
31note "Created new volume $vol with name ", $vol->name;
32is $sw->volume($vol)->name, $vol->name, 'get_volume';
33my @vols = $sw->volumes;
34ok grep ({$_->name eq $vol->name} @vols), 'list_volumes';
35
36my ($debian) = grep { $_->name =~ /debian jessie/i } $sw->images;
37my $srv = $sw->create_server('mysrv', $org, $debian, {1 => $vol->id});
38note "Created new server $srv with name ", $srv->name;
39is $sw->server($srv)->name, $srv->name, 'get_server';
40$srv->{name} = 'testsrv';
41$sw->update_server($srv);
42is $sw->server($srv)->name, $srv->name, 'update_server';
43my @srvs = $sw->servers;
44ok grep ({$_->name eq $srv->name} @srvs), 'list_servers';
45note "This server can: ", join ' ', $sw->server_actions($srv);
46
47## Snapshots are quite expensive
48#my $snp = $sw->create_snapshot('mysnap', $org, $vol);
49#note "Created new snapshot $snp with name ", $snp->name;
50#is $sw->snapshot($snp)->name, $snp->name, 'get_snapshot';
51#$snp->{name} = 'testsnap';
52#$sw->update_snapshot($snp);
53#is $sw->snapshot($snp)->name, $snp->name, 'update_snapshot';
54
55@vols = map { $_->{id} } values %{$srv->volumes};
56$sw->delete_server($srv);
57$sw->delete_ip($ip);
58$sw->delete_volume($_) for @vols;
This page took 0.029118 seconds and 5 git commands to generate.