add create and remove task

This commit is contained in:
nas 2022-02-21 18:32:46 +01:00
commit a3e14141c0
2 changed files with 34 additions and 2 deletions

View file

@ -2,6 +2,7 @@ use NRT::Test;
use NRT::Helper;
use NRT::User;
use NRT::Activity;
use NRT::Task;
package Batch;
@ -78,6 +79,12 @@ sub test_activity {
my $activity = Activity->new( "test_1", $this->get_default_user );
$this->{tester}->test_create_activity( $activity );
$this->{tester}->test_activity_exists( $activity );
my $task = Task->new( "test_1", $activity );
$this->{tester}->test_task_not_exists( $task );
$this->{tester}->test_create_task( $task );
$this->{tester}->test_task_exists( $task );
$this->{tester}->test_task_remove( $task );
$this->{tester}->test_task_not_exists( $task );
$this->{tester}->test_activity_remove( $activity );
$this->{tester}->test_activity_not_exists( $activity );
}

View file

@ -187,8 +187,8 @@ sub test_create_activity {
sub test_activity_remove {
my ($this, $activity) = @_;
return $activity->remove;
return $this->assertEqual( $ractivity->{data}{id}, $activity->{id} );
$activity->remove;
return $this->assertNotEqual( $ractivity->{data}{id}, $activity->{id} );
}
sub test_activity_exists {
@ -203,4 +203,29 @@ sub test_activity_not_exists {
return $this->assertNotEqual( $ractivity->{data}{id}, $activity->{id} );
}
sub test_create_task {
my ($this, $task) = @_;
my $res = $task->create;
return $this->assertEqual( $res->{data}{attributes}{name}, $task->{name} );
}
sub test_task_exists {
my ($this, $task) = @_;
my $rtask = $task->fetch;
return $this->assertEqual( $rtask->{data}{id}, $task->{id} );
}
sub test_task_not_exists {
my ($this, $task) = @_;
my $rtask = $task->fetch;
eval {exists $rtask->{data}{id}};
return $this->assertNotEqual( $@, 0 );
}
sub test_task_remove {
my ($this, $task) = @_;
my $rtask = $task->remove;
return $this->assertNotEqual( $rtask->{data}{id}, $task->{id} );
}
return 1;