Files
cloud-services/pkg/userconsent/mock.go

53 lines
1.2 KiB
Go

package userconsent
import (
"net/http"
"net/http/httptest"
"github.com/fiskerinc/cloud-services/pkg/common"
"github.com/fiskerinc/cloud-services/pkg/validator"
"github.com/fiskerinc/cloud-services/pkg/utils"
)
type UserConsentServiceMock struct{}
func (ucsm *UserConsentServiceMock) UserConsentByVehicleNumber(vin string) (*http.Response, error) {
w := httptest.NewRecorder()
userConsentDataArray := []common.UserConsentDataResponse{
{
VehicleIdNum: vin,
ConsentName: validator.NAV_LOCATION_DATA,
ConsentAction: "ACCEPTED",
},
{
VehicleIdNum: vin,
ConsentName: validator.CONNECTED_CAR_FEATURE,
ConsentAction: "ACCEPTED",
},
}
if vin == "9F15K3R45N1234567" {
userConsentDataArray[0].ConsentAction = "DECLINED"
}
utils.RespJSON(w, http.StatusOK, userConsentDataArray)
return w.Result(), nil
}
func (ucsm *UserConsentServiceMock) UserConsent(ucd common.UserConsentDataRequest) (*http.Response, error) {
w := httptest.NewRecorder()
userConsentDataResponse := common.UserConsentDataResponse{
VehicleIdNum: ucd.VehicleIdNum,
ConsentName: ucd.ConsentName,
ConsentAction: ucd.ConsentAction,
}
utils.RespJSON(w, http.StatusCreated, userConsentDataResponse)
return w.Result(), nil
}