@@ -6,14 +6,11 @@ import (
66
77 "github.com/lorenzodonini/ocpp-go/ocpp1.6/core"
88 "github.com/lorenzodonini/ocpp-go/ocpp1.6/types"
9- "github.com/stretchr/testify/assert"
109 "github.com/stretchr/testify/mock"
11- "github.com/stretchr/testify/require"
1210)
1311
1412// Tests
1513func (suite * OcppV16TestSuite ) TestBootNotificationRequestValidation () {
16- t := suite .T ()
1714 var requestTable = []GenericTestEntry {
1815 {core.BootNotificationRequest {ChargePointModel : "test" , ChargePointVendor : "test" }, true },
1916 {core.BootNotificationRequest {ChargeBoxSerialNumber : "test" , ChargePointModel : "test" , ChargePointSerialNumber : "number" , ChargePointVendor : "test" , FirmwareVersion : "version" , Iccid : "test" , Imsi : "test" }, true },
@@ -29,11 +26,10 @@ func (suite *OcppV16TestSuite) TestBootNotificationRequestValidation() {
2926 {core.BootNotificationRequest {ChargePointModel : "test" , ChargePointVendor : "test" , MeterSerialNumber : ">25......................." }, false },
3027 {core.BootNotificationRequest {ChargePointModel : "test" , ChargePointVendor : "test" , MeterType : ">25......................." }, false },
3128 }
32- ExecuteGenericTestTable (t , requestTable )
29+ ExecuteGenericTestTable (suite , requestTable )
3330}
3431
3532func (suite * OcppV16TestSuite ) TestBootNotificationConfirmationValidation () {
36- t := suite .T ()
3733 var confirmationTable = []GenericTestEntry {
3834 {core.BootNotificationConfirmation {CurrentTime : types .NewDateTime (time .Now ()), Interval : 60 , Status : core .RegistrationStatusAccepted }, true },
3935 {core.BootNotificationConfirmation {CurrentTime : types .NewDateTime (time .Now ()), Interval : 60 , Status : core .RegistrationStatusPending }, true },
@@ -44,11 +40,10 @@ func (suite *OcppV16TestSuite) TestBootNotificationConfirmationValidation() {
4440 {core.BootNotificationConfirmation {CurrentTime : types .NewDateTime (time .Now ()), Interval : 60 }, false },
4541 {core.BootNotificationConfirmation {Interval : 60 , Status : core .RegistrationStatusAccepted }, false },
4642 }
47- ExecuteGenericTestTable (t , confirmationTable )
43+ ExecuteGenericTestTable (suite , confirmationTable )
4844}
4945
5046func (suite * OcppV16TestSuite ) TestBootNotificationE2EMocked () {
51- t := suite .T ()
5247 wsId := "test_id"
5348 messageId := "1234"
5449 wsUrl := "someUrl"
@@ -65,23 +60,23 @@ func (suite *OcppV16TestSuite) TestBootNotificationE2EMocked() {
6560 coreListener := & MockCentralSystemCoreListener {}
6661 coreListener .On ("OnBootNotification" , mock .AnythingOfType ("string" ), mock .Anything ).Return (bootNotificationConfirmation , nil ).Run (func (args mock.Arguments ) {
6762 request , ok := args .Get (1 ).(* core.BootNotificationRequest )
68- require . True (t , ok )
69- require . NotNil (t , request )
70- assert .Equal (t , chargePointModel , request .ChargePointModel )
71- assert .Equal (t , chargePointVendor , request .ChargePointVendor )
63+ suite . Require (). True (ok )
64+ suite . Require (). NotNil (request )
65+ suite .Equal (chargePointModel , request .ChargePointModel )
66+ suite .Equal (chargePointVendor , request .ChargePointVendor )
7267 })
7368 setupDefaultCentralSystemHandlers (suite , coreListener , expectedCentralSystemOptions {clientId : wsId , rawWrittenMessage : []byte (responseJson ), forwardWrittenMessage : true })
7469 setupDefaultChargePointHandlers (suite , nil , expectedChargePointOptions {serverUrl : wsUrl , clientId : wsId , createChannelOnStart : true , channel : channel , rawWrittenMessage : []byte (requestJson ), forwardWrittenMessage : true })
7570 // Run test
7671 suite .centralSystem .Start (8887 , "somePath" )
7772 err := suite .chargePoint .Start (wsUrl )
78- require . Nil (t , err )
73+ suite . Require (). Nil (err )
7974 confirmation , err := suite .chargePoint .BootNotification (chargePointModel , chargePointVendor )
80- require . Nil (t , err )
81- require . NotNil (t , confirmation )
82- assert .Equal (t , registrationStatus , confirmation .Status )
83- assert .Equal (t , interval , confirmation .Interval )
84- assertDateTimeEquality (t , * currentTime , * confirmation .CurrentTime )
75+ suite . Require (). Nil (err )
76+ suite . Require (). NotNil (confirmation )
77+ suite .Equal (registrationStatus , confirmation .Status )
78+ suite .Equal (interval , confirmation .Interval )
79+ assertDateTimeEquality (suite , * currentTime , * confirmation .CurrentTime )
8580}
8681
8782func (suite * OcppV16TestSuite ) TestBootNotificationInvalidEndpoint () {
0 commit comments