Skip to content

Commit 55dedf6

Browse files
committed
fix test
1 parent 44b542e commit 55dedf6

File tree

4 files changed

+19
-14
lines changed

4 files changed

+19
-14
lines changed

internal/controller/netbox_testdata_test.go

+10-7
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,12 @@ var tenantSlug = "test-tenant-slug"
5353

5454
var restorationHash = "6f6c67651f0b43b2969ba2ae35c74fc91815513b"
5555

56-
var customFields = map[string]string{"example_field": "example value"}
57-
var customFieldsWithHash = map[string]string{"example_field": "example value", "netboxOperatorRestorationHash": restorationHash}
58-
var customFieldsWithHashMissmatch = map[string]string{"example_field": "example value", "netboxOperatorRestorationHash": "different hash"}
56+
var customFieldsCR = map[string]string{"example_field": "example value"}
57+
var customFieldsWithHashCR = map[string]string{"example_field": "example value", "netboxOperatorRestorationHash": restorationHash}
58+
59+
var customFields = map[string]interface{}{"example_field": "example value"}
60+
var customFieldsWithHash = map[string]interface{}{"example_field": "example value", "netboxOperatorRestorationHash": restorationHash}
61+
var customFieldsWithHashMissmatch = map[string]interface{}{"example_field": "example value", "netboxOperatorRestorationHash": "different hash"}
5962

6063
var netboxLabel = "Status"
6164
var value = "active"
@@ -73,7 +76,7 @@ func defaultIpAddressCR(preserveInNetbox bool) *netboxv1.IpAddress {
7376
Spec: netboxv1.IpAddressSpec{
7477
IpAddress: ipAddress,
7578
Tenant: tenant,
76-
CustomFields: customFields,
79+
CustomFields: customFieldsCR,
7780
Comments: comments,
7881
Description: description,
7982
PreserveInNetbox: preserveInNetbox,
@@ -90,7 +93,7 @@ func defaultIpAddressCreatedByClaim(preserveInNetbox bool) *netboxv1.IpAddress {
9093
Spec: netboxv1.IpAddressSpec{
9194
IpAddress: ipAddress,
9295
Tenant: tenant,
93-
CustomFields: customFieldsWithHash,
96+
CustomFields: customFieldsWithHashCR,
9497
Comments: comments,
9598
Description: description,
9699
PreserveInNetbox: preserveInNetbox,
@@ -107,7 +110,7 @@ func defaultIpAddressClaimCR() *netboxv1.IpAddressClaim {
107110
Spec: netboxv1.IpAddressClaimSpec{
108111
ParentPrefix: parentPrefix,
109112
Tenant: tenant,
110-
CustomFields: customFields,
113+
CustomFields: customFieldsCR,
111114
Comments: comments,
112115
Description: description,
113116
PreserveInNetbox: false,
@@ -177,7 +180,7 @@ func mockedResponsePrefixList() *ipam.IpamPrefixesListOKBody {
177180
}
178181
}
179182

180-
func mockedResponseIPAddressListWithHash(customFields map[string]string) *ipam.IpamIPAddressesListOKBody {
183+
func mockedResponseIPAddressListWithHash(customFields map[string]interface{}) *ipam.IpamIPAddressesListOKBody {
181184
return &ipam.IpamIPAddressesListOKBody{
182185
Results: []*netboxModels.IPAddress{
183186
{

pkg/netbox/api/ip_address_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ func TestIPAddress(t *testing.T) {
6262
}
6363
}
6464

65-
customFields := map[string]string{
65+
customFields := map[string]interface{}{
6666
config.GetOperatorConfig().NetboxRestorationHashFieldName: "fioaf9289rjfhaeuih",
6767
}
6868

pkg/netbox/api/ip_range_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ func TestIpRange(t *testing.T) {
199199
ID: expectedIPRange().ID,
200200
StartAddress: &startAddress,
201201
EndAddress: &endAddress,
202-
CustomFields: map[string]string{
202+
CustomFields: map[string]interface{}{
203203
config.GetOperatorConfig().NetboxRestorationHashFieldName: "different hash",
204204
},
205205
Comments: expectedIPRange().Comments,

pkg/netbox/api/prefix_test.go

+7-5
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,7 @@ func TestPrefix_ReserveOrUpdate(t *testing.T) {
387387
prefixToCreate := &netboxModels.WritablePrefix{
388388
Comments: comments + warningComment,
389389
Description: description + warningComment,
390-
CustomFields: make(map[string]string),
390+
CustomFields: make(map[string]interface{}),
391391
Prefix: prefixPtr,
392392
Site: &siteOutputId,
393393
Tenant: &tenantOutputId,
@@ -507,10 +507,12 @@ func TestPrefix_ReserveOrUpdate(t *testing.T) {
507507
Payload: &ipam.IpamPrefixesListOKBody{
508508
Results: []*netboxModels.Prefix{
509509
{
510-
ID: prefixId,
511-
CustomFields: map[string]string{config.GetOperatorConfig().NetboxRestorationHashFieldName: "hash"},
512-
Display: prefix,
513-
Prefix: &prefix,
510+
ID: prefixId,
511+
CustomFields: map[string]interface{}{
512+
config.GetOperatorConfig().NetboxRestorationHashFieldName: "hash",
513+
},
514+
Display: prefix,
515+
Prefix: &prefix,
514516
},
515517
},
516518
},

0 commit comments

Comments
 (0)