chore: rename API test suites (#938)

This commit is contained in:
kolaente
2025-06-13 10:23:17 +02:00
committed by GitHub
parent da95463bb2
commit 6671ce38a8
30 changed files with 42 additions and 42 deletions

View File

@@ -174,8 +174,8 @@ jobs:
- postgres
- mysql
test:
- unit
- integration
- feature
- web
services:
db-mysql:
image: mariadb:11@sha256:1e669024fc94f626b9dc48bf47b29b5339cec203c28e61a3dc372991a345daf5

View File

@@ -63,10 +63,10 @@ linters:
- gocyclo
- unparam
- varcheck
path: pkg/integrations/*
path: pkg/webtests/*
- linters:
- gocritic
path: pkg/integrations/*
path: pkg/webtests/*
text: unlambda
- linters:
- bodyclose

View File

@@ -15,8 +15,8 @@ The project consists of:
### Backend (Go)
- **Build**: `mage build` - Builds the Go binary
- **Test**: `mage test:unit` - Runs unit tests
- **Test Integration**: `mage test:integration` - Runs integration tests
- **Test**: `mage test:feature` - Runs feature tests
- **Test Web**: `mage test:web` - Runs web tests
- **Test All**: `mage test:all` - Runs all tests
- **Lint**: `mage lint` - Runs golangci-lint
- **Lint Fix**: `mage lint:fix` - Runs golangci-lint with auto-fix
@@ -139,7 +139,7 @@ Modern Vue 3 composition API application with TypeScript:
- Add Swagger annotations for automatic documentation generation
### Testing
- Backend: Unit tests alongside source files, integration tests in `pkg/integrations/`
- Backend: Feature tests alongside source files, web tests in `pkg/webtests/`
- Frontend: Unit tests with Vitest, E2E tests with Cypress
- Always test both positive and negative authorization scenarios
- Use test fixtures in `pkg/db/fixtures/` for consistent test data

View File

@@ -168,7 +168,7 @@ func setApiPackages() {
os.Exit(1)
}
for _, p := range strings.Split(string(pkgs), "\n") {
if strings.Contains(p, "code.vikunja.io/api") && !strings.Contains(p, "code.vikunja.io/api/pkg/integrations") {
if strings.Contains(p, "code.vikunja.io/api") && !strings.Contains(p, "code.vikunja.io/api/pkg/webtests") {
ApiPackages = append(ApiPackages, p)
}
}
@@ -376,8 +376,8 @@ func Fmt() {
type Test mg.Namespace
// Runs all tests except integration tests
func (Test) Unit() {
// Runs the feature tests
func (Test) Feature() {
mg.Deps(initVars)
setApiPackages()
// We run everything sequentially and not in parallel to prevent issues with real test databases
@@ -388,20 +388,20 @@ func (Test) Unit() {
// Runs the tests and builds the coverage html file from coverage output
func (Test) Coverage() {
mg.Deps(initVars)
mg.Deps(Test.Unit)
mg.Deps(Test.Feature)
runAndStreamOutput("go", "tool", "cover", "-html=cover.out", "-o", "cover.html")
}
// Runs the integration tests
func (Test) Integration() {
// Runs the web tests
func (Test) Web() {
mg.Deps(initVars)
// We run everything sequentially and not in parallel to prevent issues with real test databases
runAndStreamOutput("go", "test", Goflags[0], "-p", "1", "-timeout", "45m", PACKAGE+"/pkg/integrations")
runAndStreamOutput("go", "test", Goflags[0], "-p", "1", "-timeout", "45m", PACKAGE+"/pkg/webtests")
}
func (Test) All() {
mg.Deps(initVars)
mg.Deps(Test.Unit, Test.Integration)
mg.Deps(Test.Feature, Test.Web)
}
type Check mg.Namespace

View File

@@ -54,7 +54,7 @@ func CreateTestEngine() (engine *xorm.Engine, err error) {
engine.SetMapper(names.GonicMapper{})
logger := log.NewXormLogger(config.LogEnabled.GetBool(), config.LogDatabase.GetString(), "DEBUG")
logger.ShowSQL(os.Getenv("UNIT_TESTS_VERBOSE") == "1")
logger.ShowSQL(os.Getenv("TESTS_VERBOSE") == "1")
engine.SetLogger(logger)
engine.SetTZLocation(config.GetTimeZone())
x = engine

View File

@@ -25,7 +25,7 @@ import (
)
// SetupTests takes care of seting up the db, fixtures etc.
// This is an extra function to be able to call the fixtures setup from the integration tests.
// This is an extra function to be able to call the fixtures setup from the web tests.
func SetupTests() {
var err error
x, err = db.CreateTestEngine()

View File

@@ -36,7 +36,7 @@ func TestTask_Create(t *testing.T) {
Email: "user1@example.com",
}
// We only test creating a task here, the rights are all well tested in the integration tests.
// We only test creating a task here, the rights are all well tested in the web tests.
t.Run("normal", func(t *testing.T) {
db.LoadAndAssertFixtures(t)

View File

@@ -55,7 +55,7 @@ func NewUserAuthTokenResponse(u *user.User, c echo.Context, long bool) error {
return c.JSON(http.StatusOK, Token{Token: t})
}
// NewUserJWTAuthtoken generates and signes a new jwt token for a user. This is a global function to be able to call it from integration tests.
// NewUserJWTAuthtoken generates and signes a new jwt token for a user. This is a global function to be able to call it from web tests.
func NewUserJWTAuthtoken(u *user.User, long bool) (token string, err error) {
t := jwt.New(jwt.SigningMethodHS256)

View File

@@ -14,7 +14,7 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
package integrations
package webtests
import (
"code.vikunja.io/api/pkg/models"

View File

@@ -14,7 +14,7 @@
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
package integrations
package webtests
import (
"net/http"

View File

@@ -14,7 +14,7 @@
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
package integrations
package webtests
import (
"testing"
@@ -39,7 +39,7 @@ import (
// 11. Archived projects should not appear in the list with all projects.
// 12. Projects whose parent project is archived should not appear in the project with all projects.
//
// All of this is tested through integration tests because it's not yet clear if this will be implemented directly
// All of this is tested through web tests because it's not yet clear if this will be implemented directly
// or with some kind of middleware.
//
// Maybe the inheritance of projects from parents could be solved with some kind of is_archived_inherited flag -

View File

@@ -14,7 +14,7 @@
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
package integrations
package webtests
import (
"net/http"

View File

@@ -14,7 +14,7 @@
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
package integrations
package webtests
import (
"net/http"

View File

@@ -14,7 +14,7 @@
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
package integrations
package webtests
import (
"errors"

View File

@@ -14,7 +14,7 @@
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
package integrations
package webtests
import (
"testing"

View File

@@ -14,7 +14,7 @@
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
package integrations
package webtests
import (
"net/http"

View File

@@ -14,7 +14,7 @@
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
package integrations
package webtests
import (
"net/url"

View File

@@ -14,7 +14,7 @@
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
package integrations
package webtests
import (
"net/http"

View File

@@ -14,7 +14,7 @@
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
package integrations
package webtests
import (
"net/url"

View File

@@ -14,7 +14,7 @@
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
package integrations
package webtests
import (
"net/http"

View File

@@ -14,7 +14,7 @@
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
package integrations
package webtests
import (
"net/url"

View File

@@ -14,7 +14,7 @@
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
package integrations
package webtests
import (
"testing"

View File

@@ -14,7 +14,7 @@
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
package integrations
package webtests
import (
"testing"

View File

@@ -14,7 +14,7 @@
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
package integrations
package webtests
import (
"net/http"

View File

@@ -14,7 +14,7 @@
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
package integrations
package webtests
import (
"net/http"

View File

@@ -14,7 +14,7 @@
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
package integrations
package webtests
import (
"net/http"

View File

@@ -14,7 +14,7 @@
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
package integrations
package webtests
import (
"net/http"

View File

@@ -14,7 +14,7 @@
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
package integrations
package webtests
import (
"net/http"

View File

@@ -14,7 +14,7 @@
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
package integrations
package webtests
import (
"net/http"

View File

@@ -14,7 +14,7 @@
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
package integrations
package webtests
import (
"net/http"