mirror of
https://github.com/go-vikunja/vikunja.git
synced 2026-02-01 22:47:40 +00:00
chore: rename API test suites (#938)
This commit is contained in:
4
.github/workflows/test.yml
vendored
4
.github/workflows/test.yml
vendored
@@ -174,8 +174,8 @@ jobs:
|
||||
- postgres
|
||||
- mysql
|
||||
test:
|
||||
- unit
|
||||
- integration
|
||||
- feature
|
||||
- web
|
||||
services:
|
||||
db-mysql:
|
||||
image: mariadb:11@sha256:1e669024fc94f626b9dc48bf47b29b5339cec203c28e61a3dc372991a345daf5
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
16
magefile.go
16
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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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()
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
|
||||
@@ -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"
|
||||
@@ -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"
|
||||
@@ -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 -
|
||||
@@ -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"
|
||||
@@ -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"
|
||||
@@ -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"
|
||||
@@ -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"
|
||||
@@ -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"
|
||||
@@ -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"
|
||||
@@ -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"
|
||||
@@ -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"
|
||||
@@ -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"
|
||||
@@ -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"
|
||||
@@ -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"
|
||||
@@ -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"
|
||||
@@ -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"
|
||||
@@ -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"
|
||||
@@ -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"
|
||||
@@ -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"
|
||||
@@ -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"
|
||||
@@ -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"
|
||||
@@ -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"
|
||||
Reference in New Issue
Block a user