[PR #1290] [MERGED] Integration test framework #15844

Closed
opened 2025-11-02 11:55:56 -06:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/go-gitea/gitea/pull/1290
Author: @ethantkoenig
Created: 3/16/2017
Status: Merged
Merged: 4/25/2017
Merged by: @lunny

Base: masterHead: test/integration


📝 Commits (4)

  • 0f746e7 Integration test framework
  • 66c8f3e udpate drone sign
  • 12fe342 Formatting fixes and move router.go to routers/
  • 5003a03 update sign for drone

📊 Changes

17 files changed (+1043 additions, -974 deletions)

View changed files

📝 .drone.yml (+13 -2)
📝 .drone.yml.sig (+1 -1)
📝 .gitignore (+1 -0)
📝 Makefile (+18 -4)
📝 cmd/web.go (+3 -629)
integrations/install_test.go (+0 -91)
integrations/integration_test.go (+92 -0)
integrations/internal/utils/utils.go (+0 -156)
integrations/mysql.ini (+56 -0)
integrations/pgsql.ini (+56 -0)
📝 integrations/signup_test.go (+28 -22)
integrations/sqlite.ini (+58 -0)
📝 integrations/version_test.go (+15 -63)
integrations/view_test.go (+32 -0)
📝 models/setup_for_test.go (+2 -6)
models/test_fixtures.go (+23 -0)
routers/routes/routes.go (+645 -0)

📄 Description

NOTE: Drone is currently failing due to .drone.yml.sig, which needs to be updated.

A new framework for integration tests. The main issues with our current integration tests are that it

  • Uses the production database
  • Re-installs the server for every test
  • Must manually add content (e.g. users, repos) to the system for every test

My proposal is to have a test "environment" (database and filesystem containing repos). The integration test environment would be populated with "fixtures", somewhat similar to what we do for unit tests (plus actual repos in the filesystem). Right now, this is implemented by having a separate app.ini for integration tests, as well as a collection of database fixtures and directory of repositories.

Also implements @andreynering's suggestion from https://github.com/go-gitea/gitea/pull/1135#discussion_r105298393 of using the ServeHTTP(..) method

This system would allow us to not only add integration tests, but also unit tests for components that interact with the filesystem (e.g. anything that runs git commands).

STORING THE INTEGRATION ENVIRONMENT:
In order to not have to store a bunch of test fixtures and repos inside the main gitea repository, I have created a separate repo (https://github.com/ethantkoenig/gitea-integration) that stores the integration test fixtures and repositories. This repo must be cloned to run integration tests. If we end up choosing this approach, it might make sense to transfer this repo to the go-gitea organization.

WHAT TO DO WITH EXISTING INTEGRATION TESTS:
For now, I have removed the existing integration tests to clear up the integrations/ directory. I have ported all previous integration tests to the new framework.

HOW TO RUN INTEGRATION TESTS:

  1. make test-(sqlite|mysql|pgsql). You may need to update the corresponding integrations/*.ini to match whatever you have running locally.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/go-gitea/gitea/pull/1290 **Author:** [@ethantkoenig](https://github.com/ethantkoenig) **Created:** 3/16/2017 **Status:** ✅ Merged **Merged:** 4/25/2017 **Merged by:** [@lunny](https://github.com/lunny) **Base:** `master` ← **Head:** `test/integration` --- ### 📝 Commits (4) - [`0f746e7`](https://github.com/go-gitea/gitea/commit/0f746e7a6ff5cb794290dce4ae301f169b2af9d0) Integration test framework - [`66c8f3e`](https://github.com/go-gitea/gitea/commit/66c8f3e35222b14897ba6d70111e2abda9a7c9d5) udpate drone sign - [`12fe342`](https://github.com/go-gitea/gitea/commit/12fe342bf169be50a7a53b4ddb81408381b30c09) Formatting fixes and move router.go to routers/ - [`5003a03`](https://github.com/go-gitea/gitea/commit/5003a03e9ed98ae14f78a71b2c72a01343497db6) update sign for drone ### 📊 Changes **17 files changed** (+1043 additions, -974 deletions) <details> <summary>View changed files</summary> 📝 `.drone.yml` (+13 -2) 📝 `.drone.yml.sig` (+1 -1) 📝 `.gitignore` (+1 -0) 📝 `Makefile` (+18 -4) 📝 `cmd/web.go` (+3 -629) ➖ `integrations/install_test.go` (+0 -91) ➕ `integrations/integration_test.go` (+92 -0) ➖ `integrations/internal/utils/utils.go` (+0 -156) ➕ `integrations/mysql.ini` (+56 -0) ➕ `integrations/pgsql.ini` (+56 -0) 📝 `integrations/signup_test.go` (+28 -22) ➕ `integrations/sqlite.ini` (+58 -0) 📝 `integrations/version_test.go` (+15 -63) ➕ `integrations/view_test.go` (+32 -0) 📝 `models/setup_for_test.go` (+2 -6) ➕ `models/test_fixtures.go` (+23 -0) ➕ `routers/routes/routes.go` (+645 -0) </details> ### 📄 Description __NOTE__: Drone is currently failing due to `.drone.yml.sig`, which needs to be updated. A new framework for integration tests. The main issues with our current integration tests are that it - Uses the production database - Re-installs the server for every test - Must manually add content (e.g. users, repos) to the system for every test My proposal is to have a test "environment" (database and filesystem containing repos). The integration test environment would be populated with "fixtures", somewhat similar to what we do for unit tests (plus actual repos in the filesystem). Right now, this is implemented by having a separate `app.ini` for integration tests, as well as a collection of database fixtures and directory of repositories. Also implements @andreynering's suggestion from https://github.com/go-gitea/gitea/pull/1135#discussion_r105298393 of using the `ServeHTTP(..)` method This system would allow us to not only add integration tests, but also unit tests for components that interact with the filesystem (e.g. anything that runs git commands). __STORING THE INTEGRATION ENVIRONMENT__: In order to not have to store a bunch of test fixtures and repos inside the main gitea repository, I have created a separate repo (https://github.com/ethantkoenig/gitea-integration) that stores the integration test fixtures and repositories. This repo must be cloned to run integration tests. If we end up choosing this approach, it might make sense to transfer this repo to the `go-gitea` organization. __WHAT TO DO WITH EXISTING INTEGRATION TESTS__: For now, I have removed the existing integration tests to clear up the `integrations/` directory. I have ported all previous integration tests to the new framework. __HOW TO RUN INTEGRATION TESTS__: 1. `make test-(sqlite|mysql|pgsql)`. You may need to update the corresponding `integrations/*.ini` to match whatever you have running locally. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2025-11-02 11:55:56 -06:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#15844