Skip to content

Commit 7bc78e0

Browse files
frednestolorenzodonini
authored andcommitted
fix(issue-253): fix all go vet errors
1 parent 4721000 commit 7bc78e0

14 files changed

+74
-72
lines changed

ocpp1.6_test/cancel_reservation_test.go

+4-3
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package ocpp16_test
22

33
import (
44
"fmt"
5+
56
"github.com/lorenzodonini/ocpp-go/ocpp1.6/reservation"
67
"github.com/stretchr/testify/assert"
78
"github.com/stretchr/testify/mock"
@@ -11,7 +12,7 @@ import (
1112
// Test
1213
func (suite *OcppV16TestSuite) TestCancelReservationRequestValidation() {
1314
t := suite.T()
14-
var requestTable = []GenericTestEntry{
15+
requestTable := []GenericTestEntry{
1516
{reservation.CancelReservationRequest{ReservationId: 42}, true},
1617
{reservation.CancelReservationRequest{}, true},
1718
{reservation.CancelReservationRequest{ReservationId: -1}, true},
@@ -21,7 +22,7 @@ func (suite *OcppV16TestSuite) TestCancelReservationRequestValidation() {
2122

2223
func (suite *OcppV16TestSuite) TestCancelReservationConfirmationValidation() {
2324
t := suite.T()
24-
var confirmationTable = []GenericTestEntry{
25+
confirmationTable := []GenericTestEntry{
2526
{reservation.CancelReservationConfirmation{Status: reservation.CancelReservationStatusAccepted}, true},
2627
{reservation.CancelReservationConfirmation{Status: "invalidCancelReservationStatus"}, false},
2728
{reservation.CancelReservationConfirmation{}, false},
@@ -50,7 +51,7 @@ func (suite *OcppV16TestSuite) TestCancelReservationE2EMocked() {
5051
})
5152
setupDefaultCentralSystemHandlers(suite, nil, expectedCentralSystemOptions{clientId: wsId, rawWrittenMessage: []byte(requestJson), forwardWrittenMessage: true})
5253
setupDefaultChargePointHandlers(suite, nil, expectedChargePointOptions{serverUrl: wsUrl, clientId: wsId, createChannelOnStart: true, channel: channel, rawWrittenMessage: []byte(responseJson), forwardWrittenMessage: true})
53-
suite.chargePoint.SetReservationHandler(reservationListener)
54+
suite.chargePoint.SetReservationHandler(&reservationListener)
5455
// Run Test
5556
suite.centralSystem.Start(8887, "somePath")
5657
err := suite.chargePoint.Start(wsUrl)

ocpp1.6_test/clear_charging_profile_test.go

+4-3
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package ocpp16_test
22

33
import (
44
"fmt"
5+
56
"github.com/lorenzodonini/ocpp-go/ocpp1.6/smartcharging"
67
"github.com/lorenzodonini/ocpp-go/ocpp1.6/types"
78
"github.com/stretchr/testify/assert"
@@ -12,7 +13,7 @@ import (
1213
// Test
1314
func (suite *OcppV16TestSuite) TestClearChargingProfileRequestValidation() {
1415
t := suite.T()
15-
var requestTable = []GenericTestEntry{
16+
requestTable := []GenericTestEntry{
1617
{smartcharging.ClearChargingProfileRequest{Id: newInt(1), ConnectorId: newInt(1), ChargingProfilePurpose: types.ChargingProfilePurposeChargePointMaxProfile, StackLevel: newInt(1)}, true},
1718
{smartcharging.ClearChargingProfileRequest{Id: newInt(1), ConnectorId: newInt(1), ChargingProfilePurpose: types.ChargingProfilePurposeChargePointMaxProfile}, true},
1819
{smartcharging.ClearChargingProfileRequest{Id: newInt(1), ConnectorId: newInt(1)}, true},
@@ -28,7 +29,7 @@ func (suite *OcppV16TestSuite) TestClearChargingProfileRequestValidation() {
2829

2930
func (suite *OcppV16TestSuite) TestClearChargingProfileConfirmationValidation() {
3031
t := suite.T()
31-
var confirmationTable = []GenericTestEntry{
32+
confirmationTable := []GenericTestEntry{
3233
{smartcharging.ClearChargingProfileConfirmation{Status: smartcharging.ClearChargingProfileStatusAccepted}, true},
3334
{smartcharging.ClearChargingProfileConfirmation{Status: "invalidClearChargingProfileStatus"}, false},
3435
{smartcharging.ClearChargingProfileConfirmation{}, false},
@@ -64,7 +65,7 @@ func (suite *OcppV16TestSuite) TestClearChargingProfileE2EMocked() {
6465
})
6566
setupDefaultCentralSystemHandlers(suite, nil, expectedCentralSystemOptions{clientId: wsId, rawWrittenMessage: []byte(requestJson), forwardWrittenMessage: true})
6667
setupDefaultChargePointHandlers(suite, nil, expectedChargePointOptions{serverUrl: wsUrl, clientId: wsId, createChannelOnStart: true, channel: channel, rawWrittenMessage: []byte(responseJson), forwardWrittenMessage: true})
67-
suite.chargePoint.SetSmartChargingHandler(smartChargingListener)
68+
suite.chargePoint.SetSmartChargingHandler(&smartChargingListener)
6869
// Run Test
6970
suite.centralSystem.Start(8887, "somePath")
7071
err := suite.chargePoint.Start(wsUrl)

ocpp1.6_test/common_test.go

+7-7
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ func newFloat(f float64) *float64 {
2121

2222
// Test
2323
func (suite *OcppV16TestSuite) TestIdTagInfoValidation() {
24-
var testTable = []GenericTestEntry{
24+
testTable := []GenericTestEntry{
2525
{types.IdTagInfo{ExpiryDate: types.NewDateTime(time.Now()), ParentIdTag: "00000", Status: types.AuthorizationStatusAccepted}, true},
2626
{types.IdTagInfo{ExpiryDate: types.NewDateTime(time.Now()), Status: types.AuthorizationStatusAccepted}, true},
2727
{types.IdTagInfo{Status: types.AuthorizationStatusAccepted}, true},
@@ -38,7 +38,7 @@ func (suite *OcppV16TestSuite) TestIdTagInfoValidation() {
3838

3939
func (suite *OcppV16TestSuite) TestChargingSchedulePeriodValidation() {
4040
t := suite.T()
41-
var testTable = []GenericTestEntry{
41+
testTable := []GenericTestEntry{
4242
{types.ChargingSchedulePeriod{StartPeriod: 0, Limit: 10.0, NumberPhases: newInt(3)}, true},
4343
{types.ChargingSchedulePeriod{StartPeriod: 0, Limit: 10.0}, true},
4444
{types.ChargingSchedulePeriod{StartPeriod: 0}, true},
@@ -55,7 +55,7 @@ func (suite *OcppV16TestSuite) TestChargingScheduleValidation() {
5555
chargingSchedulePeriods := make([]types.ChargingSchedulePeriod, 2)
5656
chargingSchedulePeriods[0] = types.NewChargingSchedulePeriod(0, 10.0)
5757
chargingSchedulePeriods[1] = types.NewChargingSchedulePeriod(100, 8.0)
58-
var testTable = []GenericTestEntry{
58+
testTable := []GenericTestEntry{
5959
{types.ChargingSchedule{Duration: newInt(0), StartSchedule: types.NewDateTime(time.Now()), ChargingRateUnit: types.ChargingRateUnitWatts, ChargingSchedulePeriod: chargingSchedulePeriods, MinChargingRate: newFloat(1.0)}, true},
6060
{types.ChargingSchedule{Duration: newInt(0), ChargingRateUnit: types.ChargingRateUnitWatts, ChargingSchedulePeriod: chargingSchedulePeriods, MinChargingRate: newFloat(1.0)}, true},
6161
{types.ChargingSchedule{Duration: newInt(0), ChargingRateUnit: types.ChargingRateUnitWatts, ChargingSchedulePeriod: chargingSchedulePeriods}, true},
@@ -72,7 +72,7 @@ func (suite *OcppV16TestSuite) TestChargingScheduleValidation() {
7272
func (suite *OcppV16TestSuite) TestChargingProfileValidation() {
7373
t := suite.T()
7474
chargingSchedule := types.NewChargingSchedule(types.ChargingRateUnitWatts, types.NewChargingSchedulePeriod(0, 10.0), types.NewChargingSchedulePeriod(100, 8.0))
75-
var testTable = []GenericTestEntry{
75+
testTable := []GenericTestEntry{
7676
{types.ChargingProfile{ChargingProfileId: 1, TransactionId: 1, StackLevel: 1, ChargingProfilePurpose: types.ChargingProfilePurposeChargePointMaxProfile, ChargingProfileKind: types.ChargingProfileKindAbsolute, RecurrencyKind: types.RecurrencyKindDaily, ValidFrom: types.NewDateTime(time.Now()), ValidTo: types.NewDateTime(time.Now().Add(8 * time.Hour)), ChargingSchedule: chargingSchedule}, true},
7777
{types.ChargingProfile{ChargingProfileId: 1, StackLevel: 1, ChargingProfilePurpose: types.ChargingProfilePurposeChargePointMaxProfile, ChargingProfileKind: types.ChargingProfileKindAbsolute, ChargingSchedule: chargingSchedule}, true},
7878
{types.ChargingProfile{ChargingProfileId: 1, StackLevel: 1, ChargingProfilePurpose: types.ChargingProfilePurposeChargePointMaxProfile, ChargingProfileKind: types.ChargingProfileKindAbsolute}, false},
@@ -91,7 +91,7 @@ func (suite *OcppV16TestSuite) TestChargingProfileValidation() {
9191

9292
func (suite *OcppV16TestSuite) TestSampledValueValidation() {
9393
t := suite.T()
94-
var testTable = []GenericTestEntry{
94+
testTable := []GenericTestEntry{
9595
{types.SampledValue{Value: "value", Context: types.ReadingContextTransactionEnd, Format: types.ValueFormatRaw, Measurand: types.MeasurandPowerActiveExport, Phase: types.PhaseL2, Location: types.LocationBody, Unit: types.UnitOfMeasureKW}, true},
9696
{types.SampledValue{Value: "value", Context: types.ReadingContextTransactionEnd, Format: types.ValueFormatRaw, Measurand: types.MeasurandPowerActiveExport, Phase: types.PhaseL2, Location: types.LocationBody}, true},
9797
{types.SampledValue{Value: "value", Context: types.ReadingContextTransactionEnd, Format: types.ValueFormatRaw, Measurand: types.MeasurandPowerActiveExport, Phase: types.PhaseL2}, true},
@@ -110,7 +110,7 @@ func (suite *OcppV16TestSuite) TestSampledValueValidation() {
110110
}
111111

112112
func (suite *OcppV16TestSuite) TestMeterValueValidation() {
113-
var testTable = []GenericTestEntry{
113+
testTable := []GenericTestEntry{
114114
{types.MeterValue{Timestamp: types.NewDateTime(time.Now()), SampledValue: []types.SampledValue{{Value: "value"}, {Value: "value2", Unit: types.UnitOfMeasureKW}}}, true},
115115
{types.MeterValue{Timestamp: types.NewDateTime(time.Now()), SampledValue: []types.SampledValue{{Value: "value"}}}, true},
116116
{types.MeterValue{Timestamp: types.NewDateTime(time.Now()), SampledValue: []types.SampledValue{}}, false},
@@ -180,5 +180,5 @@ func (suite *OcppV16TestSuite) TestMarshalDateTime() {
180180
func (suite *OcppV16TestSuite) TestNowDateTime() {
181181
now := types.Now()
182182
suite.NotNil(now)
183-
suite.True(time.Now().Sub(now.Time) < 1*time.Second)
183+
suite.True(time.Since(now.Time) < 1*time.Second)
184184
}

ocpp1.6_test/diagnostics_status_notification_test.go

+4-3
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package ocpp16_test
22

33
import (
44
"fmt"
5+
56
"github.com/lorenzodonini/ocpp-go/ocpp1.6/firmware"
67
"github.com/stretchr/testify/assert"
78
"github.com/stretchr/testify/mock"
@@ -11,7 +12,7 @@ import (
1112
// Test
1213
func (suite *OcppV16TestSuite) TestDiagnosticsStatusNotificationRequestValidation() {
1314
t := suite.T()
14-
var requestTable = []GenericTestEntry{
15+
requestTable := []GenericTestEntry{
1516
{firmware.DiagnosticsStatusNotificationRequest{Status: firmware.DiagnosticsStatusUploaded}, true},
1617
{firmware.DiagnosticsStatusNotificationRequest{}, false},
1718
{firmware.DiagnosticsStatusNotificationRequest{Status: "invalidDiagnosticsStatus"}, false},
@@ -21,7 +22,7 @@ func (suite *OcppV16TestSuite) TestDiagnosticsStatusNotificationRequestValidatio
2122

2223
func (suite *OcppV16TestSuite) TestDiagnosticsStatusNotificationConfirmationValidation() {
2324
t := suite.T()
24-
var confirmationTable = []GenericTestEntry{
25+
confirmationTable := []GenericTestEntry{
2526
{firmware.DiagnosticsStatusNotificationConfirmation{}, true},
2627
}
2728
ExecuteGenericTestTable(t, confirmationTable)
@@ -46,7 +47,7 @@ func (suite *OcppV16TestSuite) TestDiagnosticsStatusNotificationE2EMocked() {
4647
assert.Equal(t, status, request.Status)
4748
})
4849
setupDefaultCentralSystemHandlers(suite, nil, expectedCentralSystemOptions{clientId: wsId, rawWrittenMessage: []byte(responseJson), forwardWrittenMessage: true})
49-
suite.centralSystem.SetFirmwareManagementHandler(firmwareListener)
50+
suite.centralSystem.SetFirmwareManagementHandler(&firmwareListener)
5051
setupDefaultChargePointHandlers(suite, nil, expectedChargePointOptions{serverUrl: wsUrl, clientId: wsId, createChannelOnStart: true, channel: channel, rawWrittenMessage: []byte(requestJson), forwardWrittenMessage: true})
5152
// Run Test
5253
suite.centralSystem.Start(8887, "somePath")

ocpp1.6_test/firmware_status_notification_test.go

+4-3
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package ocpp16_test
22

33
import (
44
"fmt"
5+
56
"github.com/lorenzodonini/ocpp-go/ocpp1.6/firmware"
67
"github.com/stretchr/testify/assert"
78
"github.com/stretchr/testify/mock"
@@ -11,7 +12,7 @@ import (
1112
// Test
1213
func (suite *OcppV16TestSuite) TestFirmwareStatusNotificationRequestValidation() {
1314
t := suite.T()
14-
var requestTable = []GenericTestEntry{
15+
requestTable := []GenericTestEntry{
1516
{firmware.FirmwareStatusNotificationRequest{Status: firmware.FirmwareStatusDownloaded}, true},
1617
{firmware.FirmwareStatusNotificationRequest{}, false},
1718
{firmware.FirmwareStatusNotificationRequest{Status: "invalidFirmwareStatus"}, false},
@@ -21,7 +22,7 @@ func (suite *OcppV16TestSuite) TestFirmwareStatusNotificationRequestValidation()
2122

2223
func (suite *OcppV16TestSuite) TestFirmwareStatusNotificationConfirmationValidation() {
2324
t := suite.T()
24-
var confirmationTable = []GenericTestEntry{
25+
confirmationTable := []GenericTestEntry{
2526
{firmware.FirmwareStatusNotificationConfirmation{}, true},
2627
}
2728
ExecuteGenericTestTable(t, confirmationTable)
@@ -46,7 +47,7 @@ func (suite *OcppV16TestSuite) TestFirmwareStatusNotificationE2EMocked() {
4647
assert.Equal(t, status, request.Status)
4748
})
4849
setupDefaultCentralSystemHandlers(suite, nil, expectedCentralSystemOptions{clientId: wsId, rawWrittenMessage: []byte(responseJson), forwardWrittenMessage: true})
49-
suite.centralSystem.SetFirmwareManagementHandler(firmwareListener)
50+
suite.centralSystem.SetFirmwareManagementHandler(&firmwareListener)
5051
setupDefaultChargePointHandlers(suite, nil, expectedChargePointOptions{serverUrl: wsUrl, clientId: wsId, createChannelOnStart: true, channel: channel, rawWrittenMessage: []byte(requestJson), forwardWrittenMessage: true})
5152
// Run Test
5253
suite.centralSystem.Start(8887, "somePath")

ocpp1.6_test/get_composite_schedule_test.go

+5-4
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,19 @@ package ocpp16_test
22

33
import (
44
"fmt"
5+
"time"
6+
57
"github.com/lorenzodonini/ocpp-go/ocpp1.6/smartcharging"
68
"github.com/lorenzodonini/ocpp-go/ocpp1.6/types"
79
"github.com/stretchr/testify/assert"
810
"github.com/stretchr/testify/mock"
911
"github.com/stretchr/testify/require"
10-
"time"
1112
)
1213

1314
// Test
1415
func (suite *OcppV16TestSuite) TestGetCompositeScheduleRequestValidation() {
1516
t := suite.T()
16-
var requestTable = []GenericTestEntry{
17+
requestTable := []GenericTestEntry{
1718
{smartcharging.GetCompositeScheduleRequest{ConnectorId: 1, Duration: 600, ChargingRateUnit: types.ChargingRateUnitWatts}, true},
1819
{smartcharging.GetCompositeScheduleRequest{ConnectorId: 1, Duration: 600}, true},
1920
{smartcharging.GetCompositeScheduleRequest{ConnectorId: 1}, true},
@@ -28,7 +29,7 @@ func (suite *OcppV16TestSuite) TestGetCompositeScheduleRequestValidation() {
2829
func (suite *OcppV16TestSuite) TestGetCompositeScheduleConfirmationValidation() {
2930
t := suite.T()
3031
chargingSchedule := types.NewChargingSchedule(types.ChargingRateUnitWatts, types.NewChargingSchedulePeriod(0, 10.0))
31-
var confirmationTable = []GenericTestEntry{
32+
confirmationTable := []GenericTestEntry{
3233
{smartcharging.GetCompositeScheduleConfirmation{Status: smartcharging.GetCompositeScheduleStatusAccepted, ConnectorId: newInt(1), ScheduleStart: types.NewDateTime(time.Now()), ChargingSchedule: chargingSchedule}, true},
3334
{smartcharging.GetCompositeScheduleConfirmation{Status: smartcharging.GetCompositeScheduleStatusAccepted, ConnectorId: newInt(1), ScheduleStart: types.NewDateTime(time.Now())}, true},
3435
{smartcharging.GetCompositeScheduleConfirmation{Status: smartcharging.GetCompositeScheduleStatusAccepted, ConnectorId: newInt(1)}, true},
@@ -75,7 +76,7 @@ func (suite *OcppV16TestSuite) TestGetCompositeScheduleE2EMocked() {
7576
})
7677
setupDefaultCentralSystemHandlers(suite, nil, expectedCentralSystemOptions{clientId: wsId, rawWrittenMessage: []byte(requestJson), forwardWrittenMessage: true})
7778
setupDefaultChargePointHandlers(suite, nil, expectedChargePointOptions{serverUrl: wsUrl, clientId: wsId, createChannelOnStart: true, channel: channel, rawWrittenMessage: []byte(responseJson), forwardWrittenMessage: true})
78-
suite.chargePoint.SetSmartChargingHandler(smartChargingListener)
79+
suite.chargePoint.SetSmartChargingHandler(&smartChargingListener)
7980
// Run Test
8081
suite.centralSystem.Start(8887, "somePath")
8182
err := suite.chargePoint.Start(wsUrl)

ocpp1.6_test/get_diagnostics_test.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import (
1414
// Test
1515
func (suite *OcppV16TestSuite) TestGetDiagnosticsRequestValidation() {
1616
t := suite.T()
17-
var requestTable = []GenericTestEntry{
17+
requestTable := []GenericTestEntry{
1818
{firmware.GetDiagnosticsRequest{Location: "ftp:some/path", Retries: newInt(10), RetryInterval: newInt(10), StartTime: types.NewDateTime(time.Now()), StopTime: types.NewDateTime(time.Now())}, true},
1919
{firmware.GetDiagnosticsRequest{Location: "ftp:some/path", Retries: newInt(10), RetryInterval: newInt(10), StartTime: types.NewDateTime(time.Now())}, true},
2020
{firmware.GetDiagnosticsRequest{Location: "ftp:some/path", Retries: newInt(10), RetryInterval: newInt(10)}, true},
@@ -30,7 +30,7 @@ func (suite *OcppV16TestSuite) TestGetDiagnosticsRequestValidation() {
3030

3131
func (suite *OcppV16TestSuite) TestGetDiagnosticsConfirmationValidation() {
3232
t := suite.T()
33-
var confirmationTable = []GenericTestEntry{
33+
confirmationTable := []GenericTestEntry{
3434
{firmware.GetDiagnosticsConfirmation{FileName: "someFileName"}, true},
3535
{firmware.GetDiagnosticsConfirmation{FileName: ""}, true},
3636
{firmware.GetDiagnosticsConfirmation{}, true},
@@ -71,7 +71,7 @@ func (suite *OcppV16TestSuite) TestGetDiagnosticsE2EMocked() {
7171
assertDateTimeEquality(t, *stopTime, *request.StopTime)
7272
})
7373
setupDefaultCentralSystemHandlers(suite, nil, expectedCentralSystemOptions{clientId: wsId, rawWrittenMessage: []byte(requestJson), forwardWrittenMessage: true})
74-
suite.chargePoint.SetFirmwareManagementHandler(firmwareListener)
74+
suite.chargePoint.SetFirmwareManagementHandler(&firmwareListener)
7575
setupDefaultChargePointHandlers(suite, nil, expectedChargePointOptions{serverUrl: wsUrl, clientId: wsId, createChannelOnStart: true, channel: channel, rawWrittenMessage: []byte(responseJson), forwardWrittenMessage: true})
7676
// Run Test
7777
suite.centralSystem.Start(8887, "somePath")

ocpp1.6_test/get_local_list_version_test.go

+4-3
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package ocpp16_test
22

33
import (
44
"fmt"
5+
56
"github.com/lorenzodonini/ocpp-go/ocpp1.6/localauth"
67
"github.com/stretchr/testify/assert"
78
"github.com/stretchr/testify/mock"
@@ -11,15 +12,15 @@ import (
1112
// Test
1213
func (suite *OcppV16TestSuite) TestGetLocalListVersionRequestValidation() {
1314
t := suite.T()
14-
var requestTable = []GenericTestEntry{
15+
requestTable := []GenericTestEntry{
1516
{localauth.GetLocalListVersionRequest{}, true},
1617
}
1718
ExecuteGenericTestTable(t, requestTable)
1819
}
1920

2021
func (suite *OcppV16TestSuite) TestGetLocalListVersionConfirmationValidation() {
2122
t := suite.T()
22-
var confirmationTable = []GenericTestEntry{
23+
confirmationTable := []GenericTestEntry{
2324
{localauth.GetLocalListVersionConfirmation{ListVersion: 1}, true},
2425
{localauth.GetLocalListVersionConfirmation{ListVersion: 0}, true},
2526
{localauth.GetLocalListVersionConfirmation{}, true},
@@ -47,7 +48,7 @@ func (suite *OcppV16TestSuite) TestGetLocalListVersionE2EMocked() {
4748
require.True(t, ok)
4849
})
4950
setupDefaultCentralSystemHandlers(suite, nil, expectedCentralSystemOptions{clientId: wsId, rawWrittenMessage: []byte(requestJson), forwardWrittenMessage: true})
50-
suite.chargePoint.SetLocalAuthListHandler(localAuthListListener)
51+
suite.chargePoint.SetLocalAuthListHandler(&localAuthListListener)
5152
setupDefaultChargePointHandlers(suite, nil, expectedChargePointOptions{serverUrl: wsUrl, clientId: wsId, createChannelOnStart: true, channel: channel, rawWrittenMessage: []byte(responseJson), forwardWrittenMessage: true})
5253
// Run Test
5354
suite.centralSystem.Start(8887, "somePath")

0 commit comments

Comments
 (0)