mirror of
https://gitlab.dit.htwk-leipzig.de/htwk-software/htwkalender.git
synced 2025-08-03 02:09:15 +02:00
feat:#65 adjusted missing changes backend migration
This commit is contained in:
@@ -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)
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user