Skip to content
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

Merged
merged 10 commits into from Dec 13, 2020
Merged

Integration test for Web API #2578

merged 10 commits into from Dec 13, 2020

Conversation

takezoe
Copy link
Member

@takezoe takezoe commented Oct 10, 2020

Before submitting a pull-request to GitBucket I have first:

  • read the contribution guidelines
  • rebased my branch over master
  • verified that project is compiling
  • verified that tests are passing
  • squashed my commits as appropriate (keep several commits if it is relevant to understand the PR)
  • marked as closed using commit message all issue ID that this PR should correct

@takezoe
Copy link
Member Author

takezoe commented Oct 14, 2020

@onukura This can be a base of integration tests for Web API. What do you feel about this?

@takezoe takezoe requested a review from onukura October 14, 2020 15:26
@takezoe takezoe changed the title [WIP] Integration test Integration test for Web API Oct 14, 2020
Comment on lines 23 to 70
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")
}
}
Copy link
Member

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!

@onukura
Copy link
Member

onukura commented Oct 15, 2020

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...

@takezoe
Copy link
Member Author

takezoe commented Oct 17, 2020

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.

@takezoe
Copy link
Member Author

takezoe commented Nov 3, 2020

Added test cases for pull request status as examples of complex test cases.

By the way, this integration test requires to run ./sbt package in advance to setup web application resources for the embedded Jetty. However, I think it would be nice if we can resolve it without running sbt.

@takezoe takezoe merged commit 8d88455 into master Dec 13, 2020
@takezoe takezoe deleted the integration-test branch December 13, 2020 12:04
@takezoe takezoe added this to the 4.35.0 milestone Dec 13, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants