New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Integration test for Web API #2578
Conversation
6cb6104
to
2e66d2f
Compare
7dbc9b1
to
4301c59
Compare
4301c59
to
1b0dd06
Compare
@onukura This can be a base of integration tests for Web API. What do you feel about this? |
test("API integration test") { | ||
Using.resource(new TestingGitBucketServer(19999)) { server => | ||
server.start() | ||
|
||
val github = GitHub.connectToEnterprise(s"http://localhost:${server.port}/api/v3", "root", "root") | ||
|
||
{ | ||
val repository = github | ||
.createRepository("test") | ||
.description("test repository") | ||
.private_(false) | ||
.autoInit(true) | ||
.create() | ||
|
||
assert(repository.getName == "test") | ||
assert(repository.getDescription == "test repository") | ||
assert(repository.getDefaultBranch == "master") | ||
assert(repository.getWatchers == 0) | ||
assert(repository.getWatchersCount == 0) | ||
assert(repository.getForks == 0) | ||
assert(repository.getForksCount == 0) | ||
assert(repository.isPrivate == false) | ||
assert(repository.getOwner.getLogin == "root") | ||
assert(repository.hasIssues == true) | ||
assert(repository.getUrl.toString == s"http://localhost:${server.port}/api/v3/repos/root/test") | ||
assert(repository.getHttpTransportUrl == s"http://localhost:${server.port}/git/root/test.git") | ||
assert(repository.getHtmlUrl.toString == s"http://localhost:${server.port}/root/test") | ||
} | ||
{ | ||
val repositories = github.getUser("root").listRepositories().toList | ||
assert(repositories.size() == 1) | ||
|
||
val repository = repositories.get(0) | ||
assert(repository.getName == "test") | ||
assert(repository.getDescription == "test repository") | ||
assert(repository.getDefaultBranch == "master") | ||
assert(repository.getWatchers == 0) | ||
assert(repository.getWatchersCount == 0) | ||
assert(repository.getForks == 0) | ||
assert(repository.getForksCount == 0) | ||
assert(repository.isPrivate == false) | ||
assert(repository.getOwner.getLogin == "root") | ||
assert(repository.hasIssues == true) | ||
assert(repository.getUrl.toString == s"http://localhost:${server.port}/api/v3/repos/root/test") | ||
assert(repository.getHttpTransportUrl == s"http://localhost:${server.port}/git/root/test.git") | ||
assert(repository.getHtmlUrl.toString == s"http://localhost:${server.port}/root/test") | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@takezoe At first thank you for your work about API test basement!
I guess we will need add this kind of part for each endpoint, right?? It might be a lot of work, but it is also what we should do for reliability of API. I agree with your idea!
And I really need to know about this framework because I have no idea how test will be if endpoint is more complicated one like PR and StatusChecks... |
I don't yet have an idea for the complicated cases. I would like to try such cases in this pull request to find a way. |
1400ccf
to
683d85d
Compare
Added test cases for pull request status as examples of complex test cases. By the way, this integration test requires to run |
Before submitting a pull-request to GitBucket I have first: