Skip to content

Commit c09f050

Browse files
authored
fix: Initialize resourcesCache for new device profile client (#1002)
Signed-off-by: Jeff Titus <[email protected]>
1 parent 7946959 commit c09f050

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

clients/http/deviceprofile.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ func NewDeviceProfileClientWithUrlCallback(baseUrlFunc clients.ClientBaseUrlFunc
4848
return &DeviceProfileClient{
4949
baseUrlFunc: baseUrlFunc,
5050
authInjector: authInjector,
51+
resourcesCache: make(map[string]responses.DeviceResourceResponse),
5152
enableNameFieldEscape: enableNameFieldEscape,
5253
}
5354
}

clients/http/deviceprofile_test.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,20 @@ import (
2424
"github.com/edgexfoundry/go-mod-core-contracts/v4/dtos/requests"
2525
"github.com/edgexfoundry/go-mod-core-contracts/v4/dtos/responses"
2626
edgexErrors "github.com/edgexfoundry/go-mod-core-contracts/v4/errors"
27-
2827
"github.com/google/uuid"
2928
"github.com/stretchr/testify/assert"
3029
"github.com/stretchr/testify/require"
3130
)
3231

32+
func TestNewDeviceProfileClientWithUrlCallback(t *testing.T) {
33+
baseUrlFunc := func() (string, error) {
34+
return "", nil
35+
}
36+
client := NewDeviceProfileClientWithUrlCallback(baseUrlFunc, &emptyAuthenticationInjector{}, true)
37+
require.NotNil(t, client)
38+
require.NotNil(t, client.(*DeviceProfileClient).resourcesCache)
39+
}
40+
3341
func TestAddDeviceProfiles(t *testing.T) {
3442
requestId := uuid.New().String()
3543

0 commit comments

Comments
 (0)