Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
dfb6965b
Commit
dfb6965b
authored
Jun 06, 2018
by
Rémy Coutable
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Automate the basic API tests in a QA scenario
Signed-off-by:
Rémy Coutable
<
remy@rymai.me
>
parent
9e5841a0
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
61 additions
and
0 deletions
+61
-0
qa/qa/specs/features/api/basics_spec.rb
qa/qa/specs/features/api/basics_spec.rb
+61
-0
No files found.
qa/qa/specs/features/api/basics_spec.rb
0 → 100644
View file @
dfb6965b
require
'securerandom'
module
QA
feature
'API basics'
,
:core
do
before
(
:context
)
do
@api_client
=
Runtime
::
API
::
Client
.
new
(
:gitlab
)
end
let
(
:project_name
)
{
"api-basics-
#{
SecureRandom
.
hex
(
8
)
}
"
}
let
(
:sanitized_project_path
)
{
CGI
.
escape
(
"
#{
Runtime
::
User
.
name
}
/
#{
project_name
}
"
)
}
scenario
'user creates a project with a file and deletes them afterwards'
do
create_project_request
=
Runtime
::
API
::
Request
.
new
(
@api_client
,
'/projects'
)
post
create_project_request
.
url
,
path:
project_name
,
name:
project_name
expect_status
(
201
)
expect
(
json_body
).
to
match
(
a_hash_including
(
name:
project_name
,
path:
project_name
)
)
create_file_request
=
Runtime
::
API
::
Request
.
new
(
@api_client
,
"/projects/
#{
sanitized_project_path
}
/repository/files/README.md"
)
post
create_file_request
.
url
,
branch:
'master'
,
content:
'Hello world'
,
commit_message:
'Add README.md'
expect_status
(
201
)
expect
(
json_body
).
to
match
(
a_hash_including
(
branch:
'master'
,
file_path:
'README.md'
)
)
get_file_request
=
Runtime
::
API
::
Request
.
new
(
@api_client
,
"/projects/
#{
sanitized_project_path
}
/repository/files/README.md"
,
ref:
'master'
)
get
get_file_request
.
url
expect_status
(
200
)
expect
(
json_body
).
to
match
(
a_hash_including
(
ref:
'master'
,
file_path:
'README.md'
,
file_name:
'README.md'
,
encoding:
'base64'
,
content:
'SGVsbG8gd29ybGQ='
)
)
delete_file_request
=
Runtime
::
API
::
Request
.
new
(
@api_client
,
"/projects/
#{
sanitized_project_path
}
/repository/files/README.md"
,
branch:
'master'
,
commit_message:
'Remove README.md'
)
delete
delete_file_request
.
url
expect_status
(
204
)
get_tree_request
=
Runtime
::
API
::
Request
.
new
(
@api_client
,
"/projects/
#{
sanitized_project_path
}
/repository/tree"
)
get
get_tree_request
.
url
expect_status
(
200
)
expect
(
json_body
).
to
eq
([])
delete_project_request
=
Runtime
::
API
::
Request
.
new
(
@api_client
,
"/projects/
#{
sanitized_project_path
}
"
)
delete
delete_project_request
.
url
expect_status
(
202
)
expect
(
json_body
).
to
match
(
a_hash_including
(
message:
'202 Accepted'
)
)
end
end
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment