package handlers_test

import (
	"net/http"
	"testing"

	"otaupdate/handlers"
	"otaupdate/services"

	"github.com/fiskerinc/cloud-services/pkg/mongo"
	th "github.com/fiskerinc/cloud-services/pkg/testhelper"
)

func TestFleetFilterDelete(t *testing.T) {
	client, err := services.GetMongoClient()
	if err != nil {
		t.Error(err)
		return
	}
	mockMongo := mongo.NewFleetsCollection(&mongo.MockCollection{})
	client.SetFleets(mockMongo)

	tests := []th.BasicHttpTest{
		{
			Name:             "Valid data",
			Request:          th.MakeTestRequest(http.MethodDelete, "http://example.com/fleet/US-TEST/filter/123", nil),
			ExpectedStatus:   http.StatusOK,
			ExpectedResponse: `{"message":"Deleted"}`,
		},
	}

	th.RunParamHttpTests(t, tests, handlers.HandleFleetFilterDelete, "/fleet/:name/filter/:id")
}
