go-sdk icon indicating copy to clipboard operation
go-sdk copied to clipboard

Test Framework

Open klauern opened this issue 8 years ago • 6 comments

How can someone set up a test environment for adding tests to this SDK? I'm at a loss as I don't quite understand how the main gitea project is doing tests. I'd think it's possible to do something with Docker, but I'm not terribly confident that you can spin up a gitea server and then run go test with it.

Would it be possible to set up something equivalent to a golden file/db so you could use it as a baseline for tests?

klauern avatar Nov 25 '17 15:11 klauern

Thinking out loud here, but I had good experience testing and contributing to a Jenkins API using a Travis-CI build file: https://github.com/bndr/gojenkins/blob/master/.travis.yml

klauern avatar Nov 25 '17 15:11 klauern

We are using drone for testing

lafriks avatar Nov 25 '17 23:11 lafriks

https://github.com/go-gitea/go-sdk/blob/master/.drone.yml

lafriks avatar Nov 25 '17 23:11 lafriks

I think that's a great start, but I probably should have pointed to what I liked about the Travis setup:

  - docker run -d --name=jenkins -p 8080:8080 --env JAVA_OPTS=-Djenkins.install.runSetupWizard=false gojenkins

The Jenkins instance is running, so the tests work against it with a known login, etc.. I don't see any of that in the drone config. Do the sections in the pipeline all run within the same context? Can a gitea server be run in the background so the other steps in the pipeline can run a test against a running instance?

Also, does the Gitea SDK client need a token generated, or can it use a default user created with gitea admin create-user? What's the hands-free way to do that?

klauern avatar Nov 26 '17 00:11 klauern

Spinning up gitea/gitea:master as a service for running tests in easy enough. Someone just have to make tests ;)

bkcsoft avatar Dec 03 '17 20:12 bkcsoft

I'm currently using gitea as a service (GaaS :joy: ) for testing the migration tool. I've created a seperate docker image containing a gitea instance which is already set up.

gitea-service: https://git.jonasfranz.software/JonasFranzDEV/gitea-service

PR with gitea-service tests: https://git.jonasfranz.software/JonasFranzDEV/gitea-github-migrator/pulls/5

jonasfranz avatar Jun 15 '18 12:06 jonasfranz