Skip to content

Commit

Permalink
fix: Rename deviceId to deviceName from Event DTO
Browse files Browse the repository at this point in the history
Rename deviceId to deviceName in EventCountResponse DTO.

Fix edgexfoundry#330

Signed-off-by: Cloud Tsai <[email protected]>
  • Loading branch information
cloudxxx8 committed Oct 12, 2020
1 parent 70ac9f3 commit da55c3b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
6 changes: 3 additions & 3 deletions v2/dtos/responses/event.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import (
type EventCountResponse struct {
common.BaseResponse `json:",inline"`
Count uint32
DeviceId string `json:"deviceId"` // Id uniquely identifies a device
DeviceName string `json:"deviceName"`
}

// EventResponse defines the Response Content for GET event DTOs.
Expand All @@ -39,11 +39,11 @@ func NewEventCountResponseNoMessage(requestId string, statusCode int, count uint
return NewEventCountResponse(requestId, "", statusCode, count, deviceId)
}

func NewEventCountResponse(requestId string, message string, statusCode int, count uint32, deviceId string) EventCountResponse {
func NewEventCountResponse(requestId string, message string, statusCode int, count uint32, deviceName string) EventCountResponse {
return EventCountResponse{
BaseResponse: common.NewBaseResponse(requestId, message, statusCode),
Count: count,
DeviceId: deviceId,
DeviceName: deviceName,
}
}

Expand Down
12 changes: 6 additions & 6 deletions v2/dtos/responses/event_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,27 +18,27 @@ func TestNewEventCountResponse(t *testing.T) {
expectedStatusCode := 200
expectedMessage := "unit test message"
expectedCount := uint32(1000)
expectedDeviceId := "7a1707f0-166f-4c4b-bc9d-1d54c74e0137"
actual := NewEventCountResponse(expectedRequestId, expectedMessage, expectedStatusCode, expectedCount, expectedDeviceId)
expectedDeviceName := "device1"
actual := NewEventCountResponse(expectedRequestId, expectedMessage, expectedStatusCode, expectedCount, expectedDeviceName)

assert.Equal(t, expectedRequestId, actual.RequestId)
assert.Equal(t, expectedStatusCode, actual.StatusCode)
assert.Equal(t, expectedMessage, actual.Message)
assert.Equal(t, expectedCount, actual.Count)
assert.Equal(t, expectedDeviceId, actual.DeviceId)
assert.Equal(t, expectedDeviceName, actual.DeviceName)
}

func TestNewEventCountResponseNoMessage(t *testing.T) {
expectedRequestId := "123456"
expectedStatusCode := 200
expectedCount := uint32(1000)
expectedDeviceId := "7a1707f0-166f-4c4b-bc9d-1d54c74e0137"
actual := NewEventCountResponseNoMessage(expectedRequestId, expectedStatusCode, expectedCount, expectedDeviceId)
expectedDeviceName := "device1"
actual := NewEventCountResponseNoMessage(expectedRequestId, expectedStatusCode, expectedCount, expectedDeviceName)

assert.Equal(t, expectedRequestId, actual.RequestId)
assert.Equal(t, expectedStatusCode, actual.StatusCode)
assert.Equal(t, expectedCount, actual.Count)
assert.Equal(t, expectedDeviceId, actual.DeviceId)
assert.Equal(t, expectedDeviceName, actual.DeviceName)
}

func TestNewEventResponse(t *testing.T) {
Expand Down

0 comments on commit da55c3b

Please sign in to comment.