Commit graph

59 commits

Author SHA1 Message Date
zeripath 74bd9691c6
Re-attempt to delete temporary upload if the file is locked by another process ()
Replace all calls to os.Remove/os.RemoveAll by retrying util.Remove/util.RemoveAll and remove circular dependencies from util.

Fix 

Signed-off-by: Andrew Thornton <art27@cantab.net>
Co-authored-by: silverwind <me@silverwind.io>
2020-08-11 21:05:34 +01:00
techknowlogick 9e6a79bea9
upgrade to use testfixtures v3 ()
* upgrade to use testfixtures v3

* simplify logic

* make vendor

* update per @lunny

* Update templates/repo/empty.tmpl

* Update templates/repo/empty.tmpl

Co-authored-by: Lauris BH <lauris@nix.lv>
2020-06-17 22:07:58 +03:00
zeripath 14ca111f33
log slow tests ()
* log slow tests

Signed-off-by: Andrew Thornton <art27@cantab.net>

* placate lint

Signed-off-by: Andrew Thornton <art27@cantab.net>

* More lint placation

Co-authored-by: 6543 <6543@obermui.de>

Co-authored-by: 6543 <6543@obermui.de>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-06-01 21:39:44 -04:00
Terence Le Huu Phuong 141d52cc0f
Add API Endpoint for Branch Creation ()
* [FEATURE] [API] Add Endpoint for Branch Creation

Issue: https://github.com/go-gitea/gitea/issues/11376

This commit introduces an API endpoint for branch creation.

The added route is POST /repos/{owner}/{repo}/branches.
A JSON with the name of the new branch and the name of the old branch is
required as parameters.

Signed-off-by: Terence Le Huu Phuong <terence@qwasar.io>

* Put all the logic into CreateBranch and removed CreateRepoBranch

* - Added the error ErrBranchDoesNotExist in error.go
- Made the CreateNewBranch function return an errBranchDoesNotExist error
when the OldBranch does not exist
- Made the CreateBranch API function checks that the repository is not
empty and that branch exists.

* - Added a resetFixtures helper function in integration_test.go to
fine-tune test env resetting
- Added api test for CreateBranch
- Used resetFixture instead of the more general prepareTestEnv in the
repo_branch_test CreateBranch tests

* Moved the resetFixtures call inside the loop for APICreateBranch function

* Put the prepareTestEnv back in repo_branch_test

* fix import order/sort api branch test

Co-authored-by: zeripath <art27@cantab.net>
2020-05-29 19:16:20 +01:00
6543 ad5c43ae5d
Reject duplicate AccessToken names ()
* make sure duplicate token names cannot be used

* add check to api routes too

* add @lunny s suggestion

* fix & don't forget User.ID

* AccessTokenByNameExists() return error too

* unique token for each test

* fix lint

Signed-off-by: 6543 <6543@obermui.de>

Co-authored-by: Lanre Adelowo <yo@lanre.wtf>
2020-04-13 22:02:48 +03:00
guillep2k ad1b6d439f Add support for database schema in PostgreSQL ()
* Add support for database schema

* Require setting search_path for the db user

* Add schema setting to admin/config.tmpl

* Use a schema different from default for psql tests

* Update postgres scripts to use custom schema

* Update to xorm/core 0.7.3 and xorm/xorm c37aff9b3a

* Fix migration test

Co-authored-by: Antoine GIRARD <sapk@users.noreply.github.com>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2020-01-20 16:45:14 +01:00
zeripath e3c3b33ea7
Graceful: Xorm, RepoIndexer, Cron and Others ()
* Change graceful to use a singleton obtained through GetManager instead of a global.
* Graceful: Make TestPullRequests shutdownable
* Graceful: Make the cron tasks graceful
* Graceful: AddTestPullRequest run in graceful ctx
* Graceful: SyncMirrors shutdown
* Graceful: SetDefaultContext for Xorm to be HammerContext
* Avoid starting graceful for migrate commands and checkout
* Graceful: DeliverHooks now can be shutdown
* Fix multiple syncing errors in modules/sync/UniqueQueue &  Make UniqueQueue closable
* Begin the process of making the repo indexer shutdown gracefully
2019-12-15 09:51:28 +00:00
zeripath 74179d1b5e Remove SavePatch and generate patches on the fly ()
* Save patches to temporary files

* Remove SavePatch and generate patches on the fly

* Use ioutil.TempDir

* fixup! Use ioutil.TempDir

* fixup! fixup! Use ioutil.TempDir

* RemoveAll LocalCopyPath() in initIntergrationTest

* Default to status checking on PR creation

* Remove unnecessary set to StatusChecking

* Protect against unable to load repo

* Handle conflicts

* Restore original conflict setting

* In TestPullRequests update status to StatusChecking before running TestPatch
2019-12-13 23:21:06 +01:00
zeripath 055f6d2296 Fix "data race" in testlogger ()
* Fix data race in testlogger

* Update git_helper_for_declarative_test.go
2019-11-26 01:21:37 +02:00
John Olheiser 74a6add4d9 Template Repositories ()
* Start work on templates

Signed-off-by: jolheiser <john.olheiser@gmail.com>

* Continue work

Signed-off-by: jolheiser <john.olheiser@gmail.com>

* Fix IsTemplate vs IsGenerated

Signed-off-by: jolheiser <john.olheiser@gmail.com>

* Fix tabs vs spaces

* Tabs vs Spaces

* Add templates to API & start adding tests

Signed-off-by: jolheiser <john.olheiser@gmail.com>

* Fix integration tests

Signed-off-by: jolheiser <john.olheiser@gmail.com>

* Remove unused User

Signed-off-by: jolheiser <john.olheiser@gmail.com>

* Move template tests to existing repos

Signed-off-by: jolheiser <john.olheiser@gmail.com>

* Minor re-check updates and cleanup

Signed-off-by: jolheiser <john.olheiser@gmail.com>

* make fmt

Signed-off-by: jolheiser <john.olheiser@gmail.com>

* Test cleanup

Signed-off-by: jolheiser <john.olheiser@gmail.com>

* Fix optionalbool

Signed-off-by: jolheiser <john.olheiser@gmail.com>

* make fmt

Signed-off-by: jolheiser <john.olheiser@gmail.com>

* Test fixes and icon change

Signed-off-by: jolheiser <john.olheiser@gmail.com>

* Add new user and repo for tests

Signed-off-by: jolheiser <john.olheiser@gmail.com>

* Fix tests (finally)

Signed-off-by: jolheiser <john.olheiser@gmail.com>

* Update meta repo with env variables

Signed-off-by: jolheiser <john.olheiser@gmail.com>

* Move generation to create page

Combine with repo create template
Modify API search to prioritize owner for repo

Signed-off-by: jolheiser <john.olheiser@gmail.com>

* Fix tests and coverage

Signed-off-by: jolheiser <john.olheiser@gmail.com>

* Fix swagger and JS lint

Signed-off-by: jolheiser <john.olheiser@gmail.com>

* Fix API searching for own private repos

Signed-off-by: jolheiser <john.olheiser@gmail.com>

* Change wording

Signed-off-by: jolheiser <john.olheiser@gmail.com>

* Fix repo search test. User had a private repo that didn't show up

Signed-off-by: jolheiser <john.olheiser@gmail.com>

* Another search test fix

Signed-off-by: jolheiser <john.olheiser@gmail.com>

* Clarify git content

Co-Authored-By: guillep2k <18600385+guillep2k@users.noreply.github.com>

* Feedback updates

Signed-off-by: jolheiser <john.olheiser@gmail.com>

* Add topics WIP

Signed-off-by: jolheiser <john.olheiser@gmail.com>

* Finish adding topics

Signed-off-by: jolheiser <john.olheiser@gmail.com>

* Update locale

Signed-off-by: jolheiser <john.olheiser@gmail.com>
2019-11-11 23:15:29 +08:00
Lunny Xiao a8c024043c Improve integration tests ()
* improve integration tests

* fix Makefile

* improve makefile and integration docs
2019-09-25 14:13:18 +02:00
Lunny Xiao f83db078f0 Move database settings from models to setting ()
* move database settings from models to setting

* update docs

* fix checkout pr

* fix tests

* fix lint

* remove unsupported tidb options

* correct wrong variable name

* remove tidb totally
2019-08-24 11:24:45 +02:00
Tamal Saha 171b359877 Use gitea forked macaron ()
Signed-off-by: Tamal Saha <tamal@appscode.com>
2019-08-23 12:40:29 -04:00
Antoine GIRARD d02566a8ea integration tests: Use t.Helper() () 2019-07-29 12:15:18 +08:00
kolaente f9ec2f89f2 Add golangci () 2019-06-12 15:41:28 -04:00
zeripath e55c874dd2 Add work path CLI option ()
Makes it possible to set the work path as a CLI option instead of
relying on environment variables which are somewhat opaque
2019-05-14 11:20:35 -04:00
zeripath ce8de35334 Remove local clones & make hooks run on merge/edit/upload ()
* Add options to git.Clone to make it more capable

* Begin the process of removing the local copy and tidy up

* Remove Wiki LocalCopy Checkouts

* Remove the last LocalRepo helpers

* Remove WithTemporaryFile

* Enable push-hooks for these routes

* Ensure tests cope with hooks

Signed-off-by: Andrew Thornton <art27@cantab.net>

* Remove Repository.LocalCopyPath()

* Move temporary repo to use the standard temporary path

* Fix the tests

Signed-off-by: Andrew Thornton <art27@cantab.net>

* Remove LocalWikiPath

* Fix missing remove

Signed-off-by: Andrew Thornton <art27@cantab.net>

* Use AppURL for Oauth user link ()

* Use AppURL for Oauth user link

Fix 

* Update oauth.go

* Update oauth.go

* internal/ssh: ignore env command totally ()

* ssh: ignore env command totally

* Remove commented code 

Needed fix described in issue 

* Escape the commit message on issues update and title in telegram hook ()

* update sdk to latest ()

* improve description of branch protection (fix ) ()

The branch protection description text were not quite accurate.

* Fix logging documentation ()

* ENABLE_MACARON_REDIRECT should be REDIRECT_MACARON_LOG

* Allow DISABLE_ROUTER_LOG to be set in the [log] section

* [skip ci] Updated translations via Crowdin

* Move sdk structs to modules/structs ()

* move sdk structs to moduels/structs

* fix tests

* fix fmt

* fix swagger

* fix vendor
2019-05-11 11:29:17 -04:00
zeripath 8d0d7bc28d Make CustomPath, CustomConf and AppWorkPath configurable at build () 2019-04-29 14:08:21 -04:00
Richard Mahn 2262811e40 Fixes 4762 - Content API for Creating, Updating, Deleting Files () 2019-04-17 12:06:35 -04:00
zeripath c02c6a144f Fix race in integration testlogger ()
* Fix race in logger

* At testing end drop the reference to the last test.
2019-04-11 19:49:49 +08:00
zeripath 5422f23ed8 Quieter Integration Tests ()
* Rename BaseLogger to WriterLogger to help the creation of other providers

* Don't export ColorBytes and ResetBytes from ColoredValues

* Make integration tests only print logs if they fail

* check can color before coloring

* I always forget about MSSQL

* Oh and use LEVEL in sqlite.ini

* Make the test logger log at info - as it means you see the router

* Remove empty expected changes

* Make the migrations quieter too

* Don't display SQL on error - it can be looked at in the file logs if necessary

* Fix skip when using onGiteaRun
2019-04-07 03:25:14 +03:00
zeripath 2a03e96bce
Allow markdown files to read from the LFS ()
This PR makes it possible for the markdown renderer to render images and media straight from the LFS.

Fix 

Signed-off-by: Andrew Thornton [art27@cantab.net](mailto:art27@cantab.net)
2019-02-12 15:09:43 +00:00
Lunny Xiao 7fd34c0517
fix lfs version check warning log when using ssh protocol () 2018-12-19 09:17:43 +08:00
kolaente 6db7dbd333 Added test environment for mssql ()
* Added test environment for m$sql

* Added template for test environment for m$sql

* Fix password

* Fix password (again)

* Fix password (again again)

* Fix db

* Ci trigger (Looking at you drone....)

* Ci trigger (Looking at you drone....)

* Ci trigger (Looking at you drone....)

* Ci trigger (Looking at you drone....)

* Create master database for mssql integration tests

Signed-off-by: Jonas Franz <info@jonasfranz.software>

* Create database only if master do not exist

Signed-off-by: Jonas Franz <info@jonasfranz.software>

* Fix mssql integration tests by using custom database "gitea"

Signed-off-by: Jonas Franz <info@jonasfranz.software>

* Moved defer

* bump xorm

* updated xorm

* Fixed build
2018-12-12 09:01:41 +08:00
B-OnTheGo e47df0b301 Enforce token on api routes [fixed critical security issue ] () 2018-09-10 12:15:52 -04:00
techknowlogick ab55ca7ebd
Add ability to delete a token ()
Fix 
2018-07-06 21:54:30 -04:00
Lauris BH be1330ec89 Remove hardcoded paths to fix randomly failing tests ()
* Remove hardcoded paths to fix randomly failing tests

* Use correct function for merge path
2018-01-11 00:46:59 +01:00
Ethan Koenig befa7445d2 Unit tests for routers/repo/issue_label () 2017-12-15 23:11:02 +02:00
Ethan Koenig 682ac11958 Log unexpected responses in integration tests ()
* Log flash error message in integration tests

* Also log short, non-HTML responses
2017-12-11 10:15:27 +08:00
Ethan Koenig d1efe2078a Fix integration tests () 2017-12-11 08:52:05 +08:00
Ethan Koenig e59adcde65 Use httptest in integration tests () 2017-12-04 00:46:01 +02:00
Lunny Xiao f70758dec9 Add git clone test on integration test () 2017-11-02 18:51:03 +01:00
Ethan Koenig 1b6a962e70 Include HTTP method in test error message () 2017-11-01 00:54:24 -05:00
Ethan Koenig 5866eb2321 Code/repo search ()
Indexed search of repository contents (for default branch only)
2017-10-27 09:10:54 +03:00
Ethan Koenig 6c6533fb31 Make integration tests more user-friendly () 2017-09-18 16:35:42 +08:00
Ethan Koenig b0f7457d9e Improve issue search ()
* Improve issue indexer

* Fix new issue sqlite bug

* Different test indexer paths for each db

* Add integration indexer paths to make clean
2017-09-16 23:16:21 +03:00
Lunny Xiao 1739e84ac0 improve protected branch to add whitelist support ()
* improve protected branch to add whitelist support

* fix lint

* fix style check

* fix tests

* fix description on UI and import

* fix test

* bug fixed

* fix tests and languages

* move isSliceInt64Eq to util pkg; improve function names & typo
2017-09-14 16:16:22 +08:00
Antoine GIRARD 69dfe43ffc Fix some tests : make coverage -> test ()
* Fix test : make coverage -> test

* Refactor integration tests to be able to run them in parallel

* Add custom local repository temp path
2017-09-12 13:51:12 +08:00
Ethan Koenig d23b36c598 Error message for integration test () 2017-08-28 21:36:02 +08:00
David Schneiderbauer 8aadf79f80 Add integration tests for signin ()
Signed-off-by: David Schneiderbauer <dschneiderbauer@gmail.com>
2017-08-23 10:30:33 +03:00
Ethan Koenig 89cd4dd424 Cache session cookies in tests () 2017-07-09 10:07:29 +08:00
Ethan Koenig f1adaef458 Less verbose integration tests ()
* Helper functions for intergration test boilerplate
2017-07-07 21:36:47 +02:00
Ethan Koenig f64c232953 Improve integration test helper functions ()
Set request headers in helper functions, and new helper for requests with string-formatted URLs
2017-06-25 08:15:42 +08:00
Ethan Koenig 3ffedeab03 Fix bug in issue labels API () 2017-06-25 07:52:51 +08:00
Ethan Koenig 255adc40ae Don't show non-comments in comments API () 2017-06-18 17:06:17 +08:00
Bo-Yi Wu 90f9bb12c6 fix golint error and rename func for suggestion. ()
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
2017-06-17 11:29:59 -05:00
Antoine GIRARD 6233e88f7f Use testing benchmark interface () 2017-06-17 23:01:03 +08:00
Ethan Koenig ce9b86082c Consolidate boilerplate in integration tests () 2017-06-17 12:49:45 +08:00
Kim "BKC" Carlbäcker 889409ba31 Fix setting.AppPath for integration tests ()
Fix setting.AppPath for integration tests
2017-06-13 04:20:32 +02:00
Ethan Koenig 23d0735f90 Absolute path for setting.CustomConf 2017-06-09 22:27:13 -04:00