feat:#65 adjusted missing changes backend migration

This commit is contained in:
Elmar Kresse
2025-04-20 15:46:43 +02:00
parent 07f9589ea4
commit 42f5856870
24 changed files with 1348 additions and 3673 deletions

View File

@@ -14,58 +14,48 @@
//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 db
package test
import (
"github.com/pocketbase/pocketbase/daos"
"github.com/pocketbase/pocketbase"
"github.com/pocketbase/pocketbase/tests"
"htwkalender/data-manager/model/serviceModel"
"htwkalender/data-manager/service"
"net/http"
"testing"
)
const testDataDir = "./mockData"
const testDataDir = "../mockData"
func TestDeleteFeed(t *testing.T) {
setupTestApp := func(t *testing.T) *daos.Dao {
setupTestApp := func(t testing.TB) *tests.TestApp {
testApp, err := tests.NewTestApp(testDataDir)
if err != nil {
t.Fatal(err)
}
dao := daos.New(testApp.Dao().DB())
return dao
base := &pocketbase.PocketBase{App: testApp}
services := serviceModel.Service{App: base}
service.AddRoutes(services)
return testApp
}
type args struct {
db *daos.Dao
feedId string
}
testsCases := []struct {
name string
args args
wantErr bool
}{
scenarios := []tests.ApiScenario{
{
name: "TestDeleteFeed",
args: args{
db: setupTestApp(t),
feedId: "fkoqti06ohlnsb8",
},
wantErr: false,
},
{
name: "TestDeleteFeedNotExisting",
args: args{
db: setupTestApp(t),
feedId: "test324",
},
wantErr: true,
Name: "TestDeleteFeed",
Method: "DELETE",
URL: "/api/v1/feeds/fkoqti06ohlnsb8",
ExpectedStatus: http.StatusNotFound,
ExpectedContent: []string{"\"data\":{},\"message\":\"The requested resource wasn't found.\",\"status\":404"},
TestAppFactory: setupTestApp,
},
}
for _, tt := range testsCases {
t.Run(tt.name, func(t *testing.T) {
if err := DeleteFeed(tt.args.db, tt.args.feedId); (err != nil) != tt.wantErr {
t.Errorf("DeleteFeed() error = %v, wantErr %v", err, tt.wantErr)
}
})
for _, scenario := range scenarios {
scenario.Test(t)
}
}