diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 359c2397c..83fc0e6f1 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -174,8 +174,8 @@ jobs: - postgres - mysql test: - - unit - - integration + - feature + - web services: db-mysql: image: mariadb:11@sha256:1e669024fc94f626b9dc48bf47b29b5339cec203c28e61a3dc372991a345daf5 diff --git a/.golangci.yml b/.golangci.yml index d812af1a7..67d0f0d99 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -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 diff --git a/AGENTS.md b/AGENTS.md index 472cfc468..5d235f87b 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -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 diff --git a/magefile.go b/magefile.go index 4c61bef8c..4accd3f7f 100644 --- a/magefile.go +++ b/magefile.go @@ -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 diff --git a/pkg/db/test.go b/pkg/db/test.go index 622a6ae83..4c4859c8e 100644 --- a/pkg/db/test.go +++ b/pkg/db/test.go @@ -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 diff --git a/pkg/models/unit_tests.go b/pkg/models/setup_tests.go similarity index 98% rename from pkg/models/unit_tests.go rename to pkg/models/setup_tests.go index 7b0eacb8d..18e5587bb 100644 --- a/pkg/models/unit_tests.go +++ b/pkg/models/setup_tests.go @@ -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() diff --git a/pkg/models/tasks_test.go b/pkg/models/tasks_test.go index 2494df3ae..e5fedf1d8 100644 --- a/pkg/models/tasks_test.go +++ b/pkg/models/tasks_test.go @@ -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) diff --git a/pkg/modules/auth/auth.go b/pkg/modules/auth/auth.go index 2afaf1dde..bfb9887b1 100644 --- a/pkg/modules/auth/auth.go +++ b/pkg/modules/auth/auth.go @@ -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) diff --git a/pkg/integrations/_test.go.tpl b/pkg/webtests/_test.go.tpl similarity index 99% rename from pkg/integrations/_test.go.tpl rename to pkg/webtests/_test.go.tpl index 92c9ffef5..a6e755595 100644 --- a/pkg/integrations/_test.go.tpl +++ b/pkg/webtests/_test.go.tpl @@ -14,7 +14,7 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see . -package integrations +package webtests import ( "code.vikunja.io/api/pkg/models" diff --git a/pkg/integrations/api_tokens_test.go b/pkg/webtests/api_tokens_test.go similarity index 99% rename from pkg/integrations/api_tokens_test.go rename to pkg/webtests/api_tokens_test.go index 5e92eba0c..5b1ffefeb 100644 --- a/pkg/integrations/api_tokens_test.go +++ b/pkg/webtests/api_tokens_test.go @@ -14,7 +14,7 @@ // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . -package integrations +package webtests import ( "net/http" diff --git a/pkg/integrations/archived_test.go b/pkg/webtests/archived_test.go similarity index 98% rename from pkg/integrations/archived_test.go rename to pkg/webtests/archived_test.go index d70c479a9..ad7d214c9 100644 --- a/pkg/integrations/archived_test.go +++ b/pkg/webtests/archived_test.go @@ -14,7 +14,7 @@ // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . -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 - diff --git a/pkg/integrations/caldav_test.go b/pkg/webtests/caldav_test.go similarity index 99% rename from pkg/integrations/caldav_test.go rename to pkg/webtests/caldav_test.go index 1a98181d7..c255bb4da 100644 --- a/pkg/integrations/caldav_test.go +++ b/pkg/webtests/caldav_test.go @@ -14,7 +14,7 @@ // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . -package integrations +package webtests import ( "net/http" diff --git a/pkg/integrations/healthcheck_test.go b/pkg/webtests/healthcheck_test.go similarity index 98% rename from pkg/integrations/healthcheck_test.go rename to pkg/webtests/healthcheck_test.go index c76d7f29d..c8607142d 100644 --- a/pkg/integrations/healthcheck_test.go +++ b/pkg/webtests/healthcheck_test.go @@ -14,7 +14,7 @@ // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . -package integrations +package webtests import ( "net/http" diff --git a/pkg/integrations/integrations.go b/pkg/webtests/integrations.go similarity index 99% rename from pkg/integrations/integrations.go rename to pkg/webtests/integrations.go index 629f3f213..434dc6373 100644 --- a/pkg/integrations/integrations.go +++ b/pkg/webtests/integrations.go @@ -14,7 +14,7 @@ // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . -package integrations +package webtests import ( "errors" diff --git a/pkg/integrations/kanban_test.go b/pkg/webtests/kanban_test.go similarity index 99% rename from pkg/integrations/kanban_test.go rename to pkg/webtests/kanban_test.go index 512cc56a3..75eb9dce0 100644 --- a/pkg/integrations/kanban_test.go +++ b/pkg/webtests/kanban_test.go @@ -14,7 +14,7 @@ // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . -package integrations +package webtests import ( "testing" diff --git a/pkg/integrations/link_sharing_auth_test.go b/pkg/webtests/link_sharing_auth_test.go similarity index 99% rename from pkg/integrations/link_sharing_auth_test.go rename to pkg/webtests/link_sharing_auth_test.go index a22032ab2..54c1f0324 100644 --- a/pkg/integrations/link_sharing_auth_test.go +++ b/pkg/webtests/link_sharing_auth_test.go @@ -14,7 +14,7 @@ // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . -package integrations +package webtests import ( "net/http" diff --git a/pkg/integrations/link_sharing_test.go b/pkg/webtests/link_sharing_test.go similarity index 99% rename from pkg/integrations/link_sharing_test.go rename to pkg/webtests/link_sharing_test.go index cc997bb5d..77901d0f0 100644 --- a/pkg/integrations/link_sharing_test.go +++ b/pkg/webtests/link_sharing_test.go @@ -14,7 +14,7 @@ // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . -package integrations +package webtests import ( "net/url" diff --git a/pkg/integrations/login_test.go b/pkg/webtests/login_test.go similarity index 99% rename from pkg/integrations/login_test.go rename to pkg/webtests/login_test.go index 8efddbc5d..4517e15d4 100644 --- a/pkg/integrations/login_test.go +++ b/pkg/webtests/login_test.go @@ -14,7 +14,7 @@ // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . -package integrations +package webtests import ( "net/http" diff --git a/pkg/integrations/project_test.go b/pkg/webtests/project_test.go similarity index 99% rename from pkg/integrations/project_test.go rename to pkg/webtests/project_test.go index 858141b6f..05e081e54 100644 --- a/pkg/integrations/project_test.go +++ b/pkg/webtests/project_test.go @@ -14,7 +14,7 @@ // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . -package integrations +package webtests import ( "net/url" diff --git a/pkg/integrations/register_test.go b/pkg/webtests/register_test.go similarity index 99% rename from pkg/integrations/register_test.go rename to pkg/webtests/register_test.go index 1c300182e..9d97f7463 100644 --- a/pkg/integrations/register_test.go +++ b/pkg/webtests/register_test.go @@ -14,7 +14,7 @@ // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . -package integrations +package webtests import ( "net/http" diff --git a/pkg/integrations/task_collection_test.go b/pkg/webtests/task_collection_test.go similarity index 99% rename from pkg/integrations/task_collection_test.go rename to pkg/webtests/task_collection_test.go index 19030ae58..ebb133df9 100644 --- a/pkg/integrations/task_collection_test.go +++ b/pkg/webtests/task_collection_test.go @@ -14,7 +14,7 @@ // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . -package integrations +package webtests import ( "net/url" diff --git a/pkg/integrations/task_comment_test.go b/pkg/webtests/task_comment_test.go similarity index 99% rename from pkg/integrations/task_comment_test.go rename to pkg/webtests/task_comment_test.go index 49b60a17a..707f97784 100644 --- a/pkg/integrations/task_comment_test.go +++ b/pkg/webtests/task_comment_test.go @@ -14,7 +14,7 @@ // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . -package integrations +package webtests import ( "testing" diff --git a/pkg/integrations/task_test.go b/pkg/webtests/task_test.go similarity index 99% rename from pkg/integrations/task_test.go rename to pkg/webtests/task_test.go index b49bb7e67..e246c9632 100644 --- a/pkg/integrations/task_test.go +++ b/pkg/webtests/task_test.go @@ -14,7 +14,7 @@ // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . -package integrations +package webtests import ( "testing" diff --git a/pkg/integrations/token_test.go b/pkg/webtests/token_test.go similarity index 98% rename from pkg/integrations/token_test.go rename to pkg/webtests/token_test.go index 366152288..27ec22ea2 100644 --- a/pkg/integrations/token_test.go +++ b/pkg/webtests/token_test.go @@ -14,7 +14,7 @@ // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . -package integrations +package webtests import ( "net/http" diff --git a/pkg/integrations/user_change_password_test.go b/pkg/webtests/user_change_password_test.go similarity index 99% rename from pkg/integrations/user_change_password_test.go rename to pkg/webtests/user_change_password_test.go index caf0610f4..6571f9ece 100644 --- a/pkg/integrations/user_change_password_test.go +++ b/pkg/webtests/user_change_password_test.go @@ -14,7 +14,7 @@ // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . -package integrations +package webtests import ( "net/http" diff --git a/pkg/integrations/user_confirm_email_test.go b/pkg/webtests/user_confirm_email_test.go similarity index 99% rename from pkg/integrations/user_confirm_email_test.go rename to pkg/webtests/user_confirm_email_test.go index f1d4b9aa0..c1fca8d21 100644 --- a/pkg/integrations/user_confirm_email_test.go +++ b/pkg/webtests/user_confirm_email_test.go @@ -14,7 +14,7 @@ // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . -package integrations +package webtests import ( "net/http" diff --git a/pkg/integrations/user_password_request_token_test.go b/pkg/webtests/user_password_request_token_test.go similarity index 99% rename from pkg/integrations/user_password_request_token_test.go rename to pkg/webtests/user_password_request_token_test.go index db308bbdc..e4ebccaca 100644 --- a/pkg/integrations/user_password_request_token_test.go +++ b/pkg/webtests/user_password_request_token_test.go @@ -14,7 +14,7 @@ // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . -package integrations +package webtests import ( "net/http" diff --git a/pkg/integrations/user_password_reset_test.go b/pkg/webtests/user_password_reset_test.go similarity index 99% rename from pkg/integrations/user_password_reset_test.go rename to pkg/webtests/user_password_reset_test.go index a0286e5d2..601f30447 100644 --- a/pkg/integrations/user_password_reset_test.go +++ b/pkg/webtests/user_password_reset_test.go @@ -14,7 +14,7 @@ // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . -package integrations +package webtests import ( "net/http" diff --git a/pkg/integrations/user_project_test.go b/pkg/webtests/user_project_test.go similarity index 98% rename from pkg/integrations/user_project_test.go rename to pkg/webtests/user_project_test.go index 07cd2dfbc..c8843d10d 100644 --- a/pkg/integrations/user_project_test.go +++ b/pkg/webtests/user_project_test.go @@ -14,7 +14,7 @@ // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . -package integrations +package webtests import ( "net/http" diff --git a/pkg/integrations/user_show_test.go b/pkg/webtests/user_show_test.go similarity index 98% rename from pkg/integrations/user_show_test.go rename to pkg/webtests/user_show_test.go index 11d2d39ca..bf7521987 100644 --- a/pkg/integrations/user_show_test.go +++ b/pkg/webtests/user_show_test.go @@ -14,7 +14,7 @@ // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . -package integrations +package webtests import ( "net/http"