Add depot, attendant, jetfire, optimus, ota services with kustomize overlays
This commit is contained in:
50
services/ota_update_go/handlers/fleet_get_test.go
Normal file
50
services/ota_update_go/handlers/fleet_get_test.go
Normal file
@@ -0,0 +1,50 @@
|
||||
package handlers_test
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"testing"
|
||||
|
||||
"otaupdate/handlers"
|
||||
"otaupdate/services"
|
||||
|
||||
"github.com/fiskerinc/cloud-services/pkg/common"
|
||||
"github.com/fiskerinc/cloud-services/pkg/mongo"
|
||||
th "github.com/fiskerinc/cloud-services/pkg/testhelper"
|
||||
"github.com/fiskerinc/cloud-services/pkg/utils/elptr"
|
||||
)
|
||||
|
||||
func TestFleetGet(t *testing.T) {
|
||||
client, err := services.GetMongoClient()
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
return
|
||||
}
|
||||
mockMongo := mongo.NewFleetsCollection(
|
||||
&mongo.MockCollection{
|
||||
AggregateObject: []mongo.Fleet{
|
||||
{
|
||||
Name: "TESTFLEET",
|
||||
CANBus: common.CANBus{DTCEnabled: elptr.ElPtr(true)},
|
||||
},
|
||||
},
|
||||
},
|
||||
)
|
||||
client.SetFleets(mockMongo)
|
||||
|
||||
tests := []th.BasicHttpTest{
|
||||
{
|
||||
Name: "Valid data",
|
||||
Request: th.MakeTestRequest(http.MethodGet, "http://example.com/fleet/INVALIDFLEET$", nil),
|
||||
ExpectedStatus: http.StatusBadRequest,
|
||||
ExpectedResponse: `{"message":"fleet fleet ","error":"Bad Request"}`,
|
||||
},
|
||||
{
|
||||
Name: "Valid data",
|
||||
Request: th.MakeTestRequest(http.MethodGet, "http://example.com/fleet/TESTFLEET", nil),
|
||||
ExpectedStatus: http.StatusOK,
|
||||
ExpectedResponse: `{"name":"","log_level":"trace","canbus":{"enabled":false,"data_logger_enabled":false,"dtc_enabled":null},"idps_enabled":false,"tags":null,"vehicles":null,"vehicles_count":0}`,
|
||||
},
|
||||
}
|
||||
|
||||
th.RunParamHttpTests(t, tests, handlers.HandleFleetGet, "/fleet/:name")
|
||||
}
|
||||
Reference in New Issue
Block a user