]> git.sur5r.net Git - i3/i3/commitdiff
add testcase for sugar methods
authorMichael Stapelberg <michael@stapelberg.de>
Tue, 23 Mar 2010 01:05:33 +0000 (02:05 +0100)
committerMichael Stapelberg <michael@stapelberg.de>
Tue, 23 Mar 2010 01:05:33 +0000 (02:05 +0100)
t/02-sugar.t [new file with mode: 0644]

diff --git a/t/02-sugar.t b/t/02-sugar.t
new file mode 100644 (file)
index 0000000..a3e2cc7
--- /dev/null
@@ -0,0 +1,29 @@
+#!perl -T
+# vim:ts=4:sw=4:expandtab
+
+use Test::More tests => 3;
+use AnyEvent::I3;
+use AnyEvent;
+
+my $i3 = i3();
+my $cv = AnyEvent->condvar;
+
+# Try to connect to i3
+$i3->connect->cb(sub { my ($v) = @_; $cv->send($v->recv) });
+
+# But cancel if we are not connected after 0.5 seconds
+my $t = AnyEvent->timer(after => 0.5, cb => sub { $cv->send(0) });
+my $connected = $cv->recv;
+
+SKIP: {
+    skip 'No connection to i3', 3 unless $connected;
+
+    my $workspaces = i3->get_workspaces->recv;
+    isa_ok($workspaces, 'ARRAY');
+
+    ok(@{$workspaces} > 0, 'More than zero workspaces found');
+
+    ok(defined(@{$workspaces}[0]->{num}), 'JSON deserialized');
+}
+
+diag( "Testing AnyEvent::I3 $AnyEvent::I3::VERSION, Perl $], $^X" );