瀏覽代碼

add create and remove task

nas 2 年之前
父節點
當前提交
a3e14141c0
共有 2 個檔案被更改,包括 34 行新增2 行删除
  1. 7
    0
      test/remote/NRT/Batch.pm
  2. 27
    2
      test/remote/NRT/Test.pm

+ 7
- 0
test/remote/NRT/Batch.pm 查看文件

@@ -2,6 +2,7 @@ use NRT::Test;
2 2
 use NRT::Helper;
3 3
 use NRT::User;
4 4
 use NRT::Activity;
5
+use NRT::Task;
5 6
 
6 7
 package Batch;
7 8
 
@@ -78,6 +79,12 @@ sub test_activity {
78 79
   my $activity = Activity->new( "test_1", $this->get_default_user );
79 80
   $this->{tester}->test_create_activity( $activity );
80 81
   $this->{tester}->test_activity_exists( $activity );
82
+  my $task = Task->new( "test_1", $activity );
83
+  $this->{tester}->test_task_not_exists( $task );
84
+  $this->{tester}->test_create_task( $task );
85
+  $this->{tester}->test_task_exists( $task );
86
+  $this->{tester}->test_task_remove( $task );
87
+  $this->{tester}->test_task_not_exists( $task );
81 88
   $this->{tester}->test_activity_remove( $activity );
82 89
   $this->{tester}->test_activity_not_exists( $activity );
83 90
 }

+ 27
- 2
test/remote/NRT/Test.pm 查看文件

@@ -187,8 +187,8 @@ sub test_create_activity {
187 187
 
188 188
 sub test_activity_remove {
189 189
   my ($this, $activity) = @_;
190
-  return $activity->remove;
191
-  return $this->assertEqual( $ractivity->{data}{id}, $activity->{id} );
190
+  $activity->remove;
191
+  return $this->assertNotEqual( $ractivity->{data}{id}, $activity->{id} );
192 192
 }
193 193
 
194 194
 sub test_activity_exists {
@@ -203,4 +203,29 @@ sub test_activity_not_exists {
203 203
   return $this->assertNotEqual( $ractivity->{data}{id}, $activity->{id} );
204 204
 }
205 205
 
206
+sub test_create_task {
207
+  my ($this, $task) = @_;
208
+  my $res = $task->create;
209
+  return $this->assertEqual( $res->{data}{attributes}{name}, $task->{name} );
210
+}
211
+
212
+sub test_task_exists {
213
+  my ($this, $task) = @_;
214
+  my $rtask = $task->fetch;
215
+  return $this->assertEqual(  $rtask->{data}{id}, $task->{id} );
216
+}
217
+
218
+sub test_task_not_exists {
219
+  my ($this, $task) = @_;
220
+  my $rtask = $task->fetch;
221
+  eval {exists $rtask->{data}{id}};
222
+  return $this->assertNotEqual( $@, 0 );
223
+}
224
+
225
+sub test_task_remove {
226
+  my ($this, $task) = @_;
227
+  my $rtask = $task->remove;
228
+  return $this->assertNotEqual( $rtask->{data}{id}, $task->{id} );
229
+}
230
+
206 231
 return 1;

Loading…
取消
儲存