~ubuntu-branches/ubuntu/wily/libpithub-perl/wily

« back to all changes in this revision

Viewing changes to t/issues.t

  • Committer: Package Import Robot
  • Author(s): gregor herrmann, Salvatore Bonaccorso, gregor herrmann
  • Date: 2013-02-18 18:34:49 UTC
  • mfrom: (1.1.1)
  • Revision ID: package-import@ubuntu.com-20130218183449-8q01hcsvuk14jpka
Tags: 0.01017-1
* Team upload.

[ Salvatore Bonaccorso ]
* Change Vcs-Git to canonical URI (git://anonscm.debian.org)
* Change search.cpan.org based URIs to metacpan.org based URIs

[ gregor herrmann ]
* New upstream release.
* Set Standards-Version to 3.9.4 (no changes).
* debian/control: remove version from perl build dependency.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
use FindBin;
2
2
use lib "$FindBin::Bin/lib";
 
3
use JSON::Any;
3
4
use Pithub::Test;
4
5
use Test::Most;
5
6
 
25
26
    ok $obj->token(123), 'Token set';
26
27
 
27
28
    {
 
29
        my $json   = JSON::Any->new;
28
30
        my $result = $obj->create(
29
31
            data => {
30
32
                assignee  => 'octocat',
37
39
        is $result->request->method, 'POST', 'HTTP method';
38
40
        is $result->request->uri->path, '/repos/foo/bar/issues', 'HTTP path';
39
41
        my $http_request = $result->request;
40
 
        is $http_request->content,
41
 
          '{"body":"I\'m having a problem with this.","assignee":"octocat","milestone":1,"title":"Found a bug","labels":["Label1","Label2"]}',
 
42
        eq_or_diff $json->decode( $http_request->content ),
 
43
          {
 
44
            'body'      => 'I\'m having a problem with this.',
 
45
            'assignee'  => 'octocat',
 
46
            'milestone' => 1,
 
47
            'title'     => 'Found a bug',
 
48
            'labels'    => [ 'Label1', 'Label2' ]
 
49
          },
42
50
          'HTTP body';
43
51
    }
44
52
}
100
108
    ok $obj->token(123), 'Token set';
101
109
 
102
110
    {
 
111
        my $json   = JSON::Any->new;
103
112
        my $result = $obj->update(
104
113
            issue_id => 123,
105
114
            data     => {
114
123
        is $result->request->method, 'PATCH', 'HTTP method';
115
124
        is $result->request->uri->path, '/repos/foo/bar/issues/123', 'HTTP path';
116
125
        my $http_request = $result->request;
117
 
        is $http_request->content,
118
 
          '{"body":"I\'m having a problem with this.","assignee":"octocat","milestone":1,"title":"Found a bug","labels":["Label1","Label2"],"state":"open"}',
 
126
        eq_or_diff $json->decode( $http_request->content ),
 
127
          {
 
128
            'body'      => 'I\'m having a problem with this.',
 
129
            'assignee'  => 'octocat',
 
130
            'milestone' => 1,
 
131
            'title'     => 'Found a bug',
 
132
            'labels'    => [ 'Label1', 'Label2' ],
 
133
            'state'     => 'open'
 
134
          },
119
135
          'HTTP body';
120
136
    }
121
137
}
137
153
    }
138
154
}
139
155
 
140
 
 
141
156
# Pithub::Issues::Assignees->list
142
157
{
143
158
    my $obj = Pithub::Test->create( 'Pithub::Issues::Assignees', user => 'foo', repo => 'bar' );
168
183
    ok $obj->token(123), 'Token set';
169
184
 
170
185
    {
 
186
        my $json   = JSON::Any->new;
171
187
        my $result = $obj->create(
172
188
            issue_id => 123,
173
189
            data     => { body => 'comment' }
175
191
        is $result->request->method, 'POST', 'HTTP method';
176
192
        is $result->request->uri->path, '/repos/foo/bar/issues/123/comments', 'HTTP path';
177
193
        my $http_request = $result->request;
178
 
        is $http_request->content, '{"body":"comment"}', 'HTTP body';
 
194
        eq_or_diff $json->decode( $http_request->content ), { 'body' => 'comment' }, 'HTTP body';
179
195
    }
180
196
}
181
197
 
247
263
    ok $obj->token(123), 'Token set';
248
264
 
249
265
    {
 
266
        my $json   = JSON::Any->new;
250
267
        my $result = $obj->update(
251
268
            comment_id => 123,
252
269
            data       => { body => 'comment' }
254
271
        is $result->request->method, 'PATCH', 'HTTP method';
255
272
        is $result->request->uri->path, '/repos/foo/bar/issues/comments/123', 'HTTP path';
256
273
        my $http_request = $result->request;
257
 
        is $http_request->content, '{"body":"comment"}', 'HTTP body';
 
274
        eq_or_diff $json->decode( $http_request->content ), { 'body' => 'comment' }, 'HTTP body';
258
275
    }
259
276
}
260
277
 
314
331
    ok $obj->token(123), 'Token set';
315
332
 
316
333
    {
 
334
        my $json   = JSON::Any->new;
317
335
        my $result = $obj->add(
318
336
            issue_id => 123,
319
337
            data     => [qw(label1 label2)],
321
339
        is $result->request->method, 'POST', 'HTTP method';
322
340
        is $result->request->uri->path, '/repos/foo/bar/issues/123/labels', 'HTTP path';
323
341
        my $http_request = $result->request;
324
 
        is $http_request->content, '["label1","label2"]', 'HTTP body';
 
342
        eq_or_diff $json->decode( $http_request->content ), [ 'label1', 'label2' ], 'HTTP body';
325
343
    }
326
344
}
327
345
 
338
356
    ok $obj->token(123), 'Token set';
339
357
 
340
358
    {
 
359
        my $json   = JSON::Any->new;
341
360
        my $result = $obj->create(
342
361
            data => {
343
362
                name  => 'label1',
347
366
        is $result->request->method, 'POST', 'HTTP method';
348
367
        is $result->request->uri->path, '/repos/foo/bar/labels', 'HTTP path';
349
368
        my $http_request = $result->request;
350
 
        is $http_request->content, '{"color":"FFFFFF","name":"label1"}', 'HTTP body';
 
369
        eq_or_diff $json->decode( $http_request->content ), { 'color' => 'FFFFFF', 'name' => 'label1' }, 'HTTP body';
351
370
    }
352
371
}
353
372
 
465
484
    ok $obj->token(123), 'Token set';
466
485
 
467
486
    {
 
487
        my $json   = JSON::Any->new;
468
488
        my $result = $obj->replace(
469
489
            issue_id => 123,
470
490
            data     => [qw(label1 label2)],
472
492
        is $result->request->method, 'PUT', 'HTTP method';
473
493
        is $result->request->uri->path, '/repos/foo/bar/issues/123/labels', 'HTTP path';
474
494
        my $http_request = $result->request;
475
 
        is $http_request->content, '["label1","label2"]', 'HTTP body';
 
495
        eq_or_diff $json->decode( $http_request->content ), [ 'label1', 'label2' ], 'HTTP body';
476
496
    }
477
497
}
478
498
 
489
509
    ok $obj->token(123), 'Token set';
490
510
 
491
511
    {
 
512
        my $json   = JSON::Any->new;
492
513
        my $result = $obj->update(
493
514
            label => 123,
494
515
            data  => {
499
520
        is $result->request->method, 'PATCH', 'HTTP method';
500
521
        is $result->request->uri->path, '/repos/foo/bar/labels/123', 'HTTP path';
501
522
        my $http_request = $result->request;
502
 
        is $http_request->content, '{"color":"FF0000","name":"label2"}', 'HTTP body';
 
523
        eq_or_diff $json->decode( $http_request->content ), { 'color' => 'FF0000', 'name' => 'label2' }, 'HTTP body';
503
524
    }
504
525
}
505
526
 
516
537
    ok $obj->token(123), 'Token set';
517
538
 
518
539
    {
 
540
        my $json   = JSON::Any->new;
519
541
        my $result = $obj->create(
520
542
            data => {
521
543
                description => 'String',
527
549
        is $result->request->method, 'POST', 'HTTP method';
528
550
        is $result->request->uri->path, '/repos/foo/bar/milestones', 'HTTP path';
529
551
        my $http_request = $result->request;
530
 
        is $http_request->content, '{"title":"String","due_on":"Time","description":"String","state":"open or closed"}', 'HTTP body';
 
552
        eq_or_diff $json->decode( $http_request->content ), { 'title' => 'String', 'due_on' => 'Time', 'description' => 'String', 'state' => 'open or closed' },
 
553
          'HTTP body';
531
554
    }
532
555
}
533
556
 
598
621
    ok $obj->token(123), 'Token set';
599
622
 
600
623
    {
 
624
        my $json   = JSON::Any->new;
601
625
        my $result = $obj->update(
602
626
            milestone_id => 123,
603
627
            data         => {
610
634
        is $result->request->method, 'PATCH', 'HTTP method';
611
635
        is $result->request->uri->path, '/repos/foo/bar/milestones/123', 'HTTP path';
612
636
        my $http_request = $result->request;
613
 
        is $http_request->content, '{"title":"String","due_on":"Time","description":"String","state":"open or closed"}', 'HTTP body';
 
637
        eq_or_diff $json->decode( $http_request->content ), { 'title' => 'String', 'due_on' => 'Time', 'description' => 'String', 'state' => 'open or closed' },
 
638
          'HTTP body';
614
639
    }
615
640
}
616
641