Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
perl-WebService-Redmine
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Gerhard Gonter
perl-WebService-Redmine
Commits
e9b1031f
Commit
e9b1031f
authored
11 years ago
by
Anton Soldatov
Browse files
Options
Downloads
Patches
Plain Diff
Adding tests for 0.0.3
parent
417646e9
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
t/00-use.t
+8
-0
8 additions, 0 deletions
t/00-use.t
t/01-dispatching.t
+159
-0
159 additions, 0 deletions
t/01-dispatching.t
with
167 additions
and
0 deletions
t/00-use.t
0 → 100644
+
8
−
0
View file @
e9b1031f
use
strict
;
use
warnings
;
use
Test::
More
tests
=>
1
;
BEGIN
{
use_ok
('
RedMiner::API
')
};
exit
;
This diff is collapsed.
Click to expand it.
t/01-dispatching.t
0 → 100644
+
159
−
0
View file @
e9b1031f
use
strict
;
use
warnings
;
use
Test::
More
;
BEGIN
{
use_ok
('
RedMiner::API
')
};
#
# Tests for internal dispatching mechanizm
#
my
$redminer
=
RedMiner::
API
->
new
(
host
=>
'',
key
=>
''
);
my
$r
;
$r
=
$redminer
->
_dispatch_name
;
ok
(
!
defined
$r
,
'
Must fail: undefined name
');
$r
=
$redminer
->
_dispatch_name
('
read
');
ok
(
!
defined
$r
,
'
Must fail: malformed name, no objects given
');
$r
=
$redminer
->
_dispatch_name
('
readproject2
');
ok
(
!
defined
$r
,
'
Must fail: malformed name, inappropriate object naming
');
$r
=
$redminer
->
_dispatch_name
('
project
',
{
id
=>
1
});
ok
(
!
defined
$r
,
'
Must fail: malformed object ID
');
$r
=
$redminer
->
_dispatch_name
('
createProject
');
ok
(
!
defined
$r
,
'
Must fail: malformed name, missing data argument for a create/update method
');
$r
=
$redminer
->
_dispatch_name
('
updateProject
',
1
);
ok
(
!
defined
$r
,
'
Must fail: malformed name, missing data argument for a create/update method
');
$r
=
$redminer
->
_dispatch_name
('
createProject
',
1
,
'
scalar
');
ok
(
!
defined
$r
,
'
Must fail: malformed name, inappropriate data type for a create/update method
');
$r
=
$redminer
->
_dispatch_name
('
updateProject
',
1
,
'
scalar
');
ok
(
!
defined
$r
,
'
Must fail: malformed name, inappropriate data type for a create/update method
');
#
# Testing basic CRUD API:
# * List existing objects (possibly with extra metadata)s
# * Read an object (possibly with extra metadata)
# * Create a new object
# * Update an existing object
# * Delete an existing object
#
$r
=
$redminer
->
_dispatch_name
('
projects
',
{
limit
=>
10
,
offset
=>
9
});
is_deeply
(
$r
,
{
method
=>
'
GET
',
path
=>
'
projects
',
content
=>
undef
,
query
=>
{
limit
=>
10
,
offset
=>
9
},
},
'
projects
');
# ditto
$r
=
$redminer
->
_dispatch_name
('
Projects
',
{
limit
=>
10
,
offset
=>
9
});
is_deeply
(
$r
,
{
method
=>
'
GET
',
path
=>
'
projects
',
content
=>
undef
,
query
=>
{
limit
=>
10
,
offset
=>
9
},
},
'
projects
');
# ditto
$r
=
$redminer
->
_dispatch_name
('
getProjects
',
{
limit
=>
10
,
offset
=>
9
});
is_deeply
(
$r
,
{
method
=>
'
GET
',
path
=>
'
projects
',
content
=>
undef
,
query
=>
{
limit
=>
10
,
offset
=>
9
},
},
'
projects
');
# ditto
$r
=
$redminer
->
_dispatch_name
('
getprojects
',
{
limit
=>
10
,
offset
=>
9
});
is_deeply
(
$r
,
{
method
=>
'
GET
',
path
=>
'
projects
',
content
=>
undef
,
query
=>
{
limit
=>
10
,
offset
=>
9
},
},
'
projects
');
# ditto
$r
=
$redminer
->
_dispatch_name
('
readProjects
',
{
limit
=>
10
,
offset
=>
9
});
is_deeply
(
$r
,
{
method
=>
'
GET
',
path
=>
'
projects
',
content
=>
undef
,
query
=>
{
limit
=>
10
,
offset
=>
9
},
},
'
projects
');
# ditto
$r
=
$redminer
->
_dispatch_name
('
readprojects
',
{
limit
=>
10
,
offset
=>
9
});
is_deeply
(
$r
,
{
method
=>
'
GET
',
path
=>
'
projects
',
content
=>
undef
,
query
=>
{
limit
=>
10
,
offset
=>
9
},
},
'
projects
');
$r
=
$redminer
->
_dispatch_name
('
project
',
1
);
is_deeply
(
$r
,
{
method
=>
'
GET
',
path
=>
'
projects/1
',
content
=>
undef
,
query
=>
undef
,
},
'
project
');
$r
=
$redminer
->
_dispatch_name
('
createProject
',
{
name
=>
'
My Project
'
});
is_deeply
(
$r
,
{
method
=>
'
POST
',
path
=>
'
projects
',
content
=>
{
project
=>
{
name
=>
'
My Project
'
}
},
query
=>
undef
,
},
'
createProject
');
$r
=
$redminer
->
_dispatch_name
('
updateProject
',
1
,
{
name
=>
'
My Project
'
});
is_deeply
(
$r
,
{
method
=>
'
PUT
',
path
=>
'
projects/1
',
content
=>
{
project
=>
{
name
=>
'
My Project
'
}
},
query
=>
undef
,
},
'
updateProject
');
$r
=
$redminer
->
_dispatch_name
('
deleteProject
',
1
);
is_deeply
(
$r
,
{
method
=>
'
DELETE
',
path
=>
'
projects/1
',
content
=>
undef
,
query
=>
undef
,
},
'
deleteProject
');
#
# Dispatching methods with more than 1 identifying object:
#
$r
=
$redminer
->
_dispatch_name
('
projectMemberships
',
1
,
{
limit
=>
10
,
offset
=>
9
});
is_deeply
(
$r
,
{
method
=>
'
GET
',
path
=>
'
projects/1/memberships
',
content
=>
undef
,
query
=>
{
limit
=>
10
,
offset
=>
9
},
},
'
projectMemberships
');
$r
=
$redminer
->
_dispatch_name
('
createProjectMembership
',
1
,
{
user_id
=>
1
,
role_ids
=>
[
1
]
});
is_deeply
(
$r
,
{
method
=>
'
POST
',
path
=>
'
projects/1/memberships
',
content
=>
{
membership
=>
{
user_id
=>
1
,
role_ids
=>
[
1
]
}
},
query
=>
undef
,
},
'
createProjectMembership
');
done_testing
;
exit
;
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment