Initial cloud-services repo - gateway service + pkg modules
This commit is contained in:
52
pkg/userconsent/mock.go
Normal file
52
pkg/userconsent/mock.go
Normal file
@@ -0,0 +1,52 @@
|
||||
package userconsent
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
|
||||
"fiskerinc.com/modules/common"
|
||||
"fiskerinc.com/modules/validator"
|
||||
"fiskerinc.com/modules/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
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user