diff --git a/pkg/modules/auth/auth_test.go b/pkg/modules/auth/auth_test.go index 1ce6f1170..8805d14a5 100644 --- a/pkg/modules/auth/auth_test.go +++ b/pkg/modules/auth/auth_test.go @@ -1,3 +1,19 @@ +// Vikunja is a to-do list application to facilitate your life. +// Copyright 2018-present Vikunja and contributors. All rights reserved. +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + package auth import ( diff --git a/pkg/modules/humaecho5/humaecho5.go b/pkg/modules/humaecho5/humaecho5.go index fd37042a3..9eefaff4e 100644 --- a/pkg/modules/humaecho5/humaecho5.go +++ b/pkg/modules/humaecho5/humaecho5.go @@ -1,3 +1,19 @@ +// Vikunja is a to-do list application to facilitate your life. +// Copyright 2018-present Vikunja and contributors. All rights reserved. +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + // Package humaecho5 is a Huma adapter for labstack/echo/v5. // // Adapted from github.com/danielgtaylor/huma/v2/adapters/humaecho (MIT) @@ -57,7 +73,7 @@ type echoCtx struct { var _ huma.Context = &echoCtx{} -func (c *echoCtx) Unwrap() *echo.Context { return c.orig } +func (c *echoCtx) Unwrap() *echo.Context { return c.orig } func (c *echoCtx) Operation() *huma.Operation { return c.op } func (c *echoCtx) Context() context.Context { diff --git a/pkg/modules/humaecho5/humaecho5_test.go b/pkg/modules/humaecho5/humaecho5_test.go index 6b9bdf753..9594ea106 100644 --- a/pkg/modules/humaecho5/humaecho5_test.go +++ b/pkg/modules/humaecho5/humaecho5_test.go @@ -1,10 +1,25 @@ +// Vikunja is a to-do list application to facilitate your life. +// Copyright 2018-present Vikunja and contributors. All rights reserved. +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + package humaecho5_test import ( "context" "encoding/json" "net/http/httptest" - "strings" "testing" "code.vikunja.io/api/pkg/modules/humaecho5" @@ -26,8 +41,8 @@ func TestAdapterRoundtrip(t *testing.T) { } type pingOutput struct { Body struct { - Echo string `json:"echo"` - HasEchoCtx bool `json:"has_echo_ctx"` + Echo string `json:"echo"` + HasEchoCtx bool `json:"has_echo_ctx"` } } @@ -66,6 +81,6 @@ func TestOpenAPISpecServed(t *testing.T) { rec := httptest.NewRecorder() e.ServeHTTP(rec, req) require.Equal(t, 200, rec.Code) - assert.True(t, strings.Contains(rec.Body.String(), `"openapi":"3.1`), + assert.Contains(t, rec.Body.String(), `"openapi":"3.1`, "expected OAS 3.1 header, got %s", rec.Body.String()) } diff --git a/pkg/routes/api/v1/humaapi/crud.go b/pkg/routes/api/v1/humaapi/crud.go index 6812b95ae..6980ffb07 100644 --- a/pkg/routes/api/v1/humaapi/crud.go +++ b/pkg/routes/api/v1/humaapi/crud.go @@ -1,3 +1,19 @@ +// Vikunja is a to-do list application to facilitate your life. +// Copyright 2018-present Vikunja and contributors. All rights reserved. +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + package humaapi import ( diff --git a/pkg/routes/api/v1/humaapi/crud_test.go b/pkg/routes/api/v1/humaapi/crud_test.go index e048e7631..d370d0c37 100644 --- a/pkg/routes/api/v1/humaapi/crud_test.go +++ b/pkg/routes/api/v1/humaapi/crud_test.go @@ -1,3 +1,19 @@ +// Vikunja is a to-do list application to facilitate your life. +// Copyright 2018-present Vikunja and contributors. All rights reserved. +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + package humaapi import ( @@ -49,7 +65,7 @@ func TestRegisterEmitsFiveOperations(t *testing.T) { e := echo.New() api := humaecho5.New(e, huma.DefaultConfig("spike", "0.0.1")) - Register[*fakeObj](api, Config[*fakeObj, SingleID]{ + Register(api, Config[*fakeObj, SingleID]{ Tag: "fakes", BasePath: "/fakes", ItemPath: "/fakes/{id}", diff --git a/pkg/routes/api/v1/humaapi/errors.go b/pkg/routes/api/v1/humaapi/errors.go index ffc45b823..6b1df12c9 100644 --- a/pkg/routes/api/v1/humaapi/errors.go +++ b/pkg/routes/api/v1/humaapi/errors.go @@ -1,3 +1,19 @@ +// Vikunja is a to-do list application to facilitate your life. +// Copyright 2018-present Vikunja and contributors. All rights reserved. +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + package humaapi import ( diff --git a/pkg/routes/api/v1/humaapi/errors_test.go b/pkg/routes/api/v1/humaapi/errors_test.go index 93eaf62bc..404dd52c3 100644 --- a/pkg/routes/api/v1/humaapi/errors_test.go +++ b/pkg/routes/api/v1/humaapi/errors_test.go @@ -1,3 +1,19 @@ +// Vikunja is a to-do list application to facilitate your life. +// Copyright 2018-present Vikunja and contributors. All rights reserved. +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + package humaapi import ( @@ -5,7 +21,6 @@ import ( "net/http" "testing" - "github.com/danielgtaylor/huma/v2" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) @@ -26,6 +41,6 @@ func TestVikunjaErrorShape_BasicCodeMessage(t *testing.T) { } func TestVikunjaErrorShape_StatusCoderInterface(t *testing.T) { - var e huma.StatusError = NewVikunjaError(http.StatusNotFound, "not found") + e := NewVikunjaError(http.StatusNotFound, "not found") assert.Equal(t, http.StatusNotFound, e.GetStatus()) } diff --git a/pkg/routes/api/v1/humaapi/labels.go b/pkg/routes/api/v1/humaapi/labels.go index cecdbceb3..a243eafea 100644 --- a/pkg/routes/api/v1/humaapi/labels.go +++ b/pkg/routes/api/v1/humaapi/labels.go @@ -1,3 +1,19 @@ +// Vikunja is a to-do list application to facilitate your life. +// Copyright 2018-present Vikunja and contributors. All rights reserved. +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + package humaapi import ( @@ -10,7 +26,7 @@ import ( // given Huma API. Runs alongside (not replacing) the legacy swag-driven // routes for the duration of the spike. func RegisterLabelRoutes(api huma.API) { - Register[*models.Label](api, Config[*models.Label, SingleID]{ + Register(api, Config[*models.Label, SingleID]{ Tag: "labels", BasePath: "/labels", ItemPath: "/labels/{id}", diff --git a/pkg/routes/routes.go b/pkg/routes/routes.go index 92ebb0079..2b641b910 100644 --- a/pkg/routes/routes.go +++ b/pkg/routes/routes.go @@ -68,6 +68,7 @@ import ( backgroundHandler "code.vikunja.io/api/pkg/modules/background/handler" "code.vikunja.io/api/pkg/modules/background/unsplash" "code.vikunja.io/api/pkg/modules/background/upload" + "code.vikunja.io/api/pkg/modules/humaecho5" "code.vikunja.io/api/pkg/modules/migration" csvmigrator "code.vikunja.io/api/pkg/modules/migration/csv" migrationHandler "code.vikunja.io/api/pkg/modules/migration/handler" @@ -78,7 +79,6 @@ import ( vikunja_file "code.vikunja.io/api/pkg/modules/migration/vikunja-file" "code.vikunja.io/api/pkg/modules/migration/wekan" "code.vikunja.io/api/pkg/plugins" - "code.vikunja.io/api/pkg/modules/humaecho5" apiv1 "code.vikunja.io/api/pkg/routes/api/v1" "code.vikunja.io/api/pkg/routes/api/v1/humaapi" "code.vikunja.io/api/pkg/routes/caldav" diff --git a/pkg/webtests/huma_label_test.go b/pkg/webtests/huma_label_test.go index eb495953e..2939a67c9 100644 --- a/pkg/webtests/huma_label_test.go +++ b/pkg/webtests/huma_label_test.go @@ -89,7 +89,7 @@ func TestHumaLabel_Create_ReadOne_via_OAS31Route(t *testing.T) { var fetched map[string]any require.NoError(t, json.Unmarshal(readRec.Body.Bytes(), &fetched)) assert.Equal(t, "spike", fetched["title"]) - assert.Equal(t, idFloat, fetched["id"]) + assert.InDelta(t, idFloat, fetched["id"], 0) } // TestHumaLabel_OpenAPISpecContainsLabelPaths proves the spec is served