From f77dee993d99ecde81d12766a6011636f1588898 Mon Sep 17 00:00:00 2001 From: 1998-felix Date: Thu, 4 Apr 2024 13:07:55 +0300 Subject: [PATCH] refactor: Rename functions Signed-off-by: 1998-felix --- things/api/http/endpoints_test.go | 24 ++++++++++++------------ things/api/http/requests.go | 4 ++-- things/api/http/requests_test.go | 8 ++++---- 3 files changed, 18 insertions(+), 18 deletions(-) diff --git a/things/api/http/endpoints_test.go b/things/api/http/endpoints_test.go index 7845e11db7..d4f8b20332 100644 --- a/things/api/http/endpoints_test.go +++ b/things/api/http/endpoints_test.go @@ -2198,7 +2198,7 @@ func TestUnassignUsers(t *testing.T) { } } -func TestAssignUserGroups(t *testing.T) { +func TestAssignGroupsToChannel(t *testing.T) { ts, _, gsvc := newThingsServer() defer ts.Close() @@ -2308,7 +2308,7 @@ func TestAssignUserGroups(t *testing.T) { } } -func TestUnassignUserGroups(t *testing.T) { +func TestUnassignGroupsFromChannel(t *testing.T) { ts, _, gsvc := newThingsServer() defer ts.Close() @@ -2418,7 +2418,7 @@ func TestUnassignUserGroups(t *testing.T) { } } -func TestConnectChannelThing(t *testing.T) { +func TestConnectThingToChannel(t *testing.T) { ts, _, gsvc := newThingsServer() defer ts.Close() @@ -2455,7 +2455,7 @@ func TestConnectChannelThing(t *testing.T) { channelID: "", thingID: validID, contentType: contentType, - status: http.StatusUnprocessableEntity, + status: http.StatusBadRequest, err: apiutil.ErrValidation, }, { @@ -2464,7 +2464,7 @@ func TestConnectChannelThing(t *testing.T) { channelID: validID, thingID: "", contentType: contentType, - status: http.StatusUnprocessableEntity, + status: http.StatusBadRequest, err: apiutil.ErrValidation, }, } @@ -2485,7 +2485,7 @@ func TestConnectChannelThing(t *testing.T) { } } -func TestDisconnectChannelThing(t *testing.T) { +func TestDisconnectThingFromChannel(t *testing.T) { ts, _, gsvc := newThingsServer() defer ts.Close() @@ -2522,7 +2522,7 @@ func TestDisconnectChannelThing(t *testing.T) { channelID: "", thingID: validID, contentType: contentType, - status: http.StatusUnprocessableEntity, + status: http.StatusBadRequest, err: apiutil.ErrValidation, }, { @@ -2531,7 +2531,7 @@ func TestDisconnectChannelThing(t *testing.T) { channelID: validID, thingID: "", contentType: contentType, - status: http.StatusUnprocessableEntity, + status: http.StatusBadRequest, err: apiutil.ErrValidation, }, } @@ -2594,7 +2594,7 @@ func TestConnect(t *testing.T) { ThingID: validID, }, contentType: contentType, - status: http.StatusUnprocessableEntity, + status: http.StatusBadRequest, err: apiutil.ErrValidation, }, { @@ -2605,7 +2605,7 @@ func TestConnect(t *testing.T) { ThingID: "", }, contentType: contentType, - status: http.StatusUnprocessableEntity, + status: http.StatusBadRequest, err: apiutil.ErrValidation, }, { @@ -2691,7 +2691,7 @@ func TestDisconnect(t *testing.T) { ThingID: validID, }, contentType: contentType, - status: http.StatusUnprocessableEntity, + status: http.StatusBadRequest, err: apiutil.ErrValidation, }, { @@ -2702,7 +2702,7 @@ func TestDisconnect(t *testing.T) { ThingID: "", }, contentType: contentType, - status: http.StatusUnprocessableEntity, + status: http.StatusBadRequest, err: apiutil.ErrValidation, }, { diff --git a/things/api/http/requests.go b/things/api/http/requests.go index 06717122d6..814ce167b9 100644 --- a/things/api/http/requests.go +++ b/things/api/http/requests.go @@ -311,7 +311,7 @@ type connectChannelThingRequest struct { func (req *connectChannelThingRequest) validate() error { if req.ThingID == "" || req.ChannelID == "" { - return svcerr.ErrCreateEntity + return apiutil.ErrMissingID } return nil } @@ -324,7 +324,7 @@ type disconnectChannelThingRequest struct { func (req *disconnectChannelThingRequest) validate() error { if req.ThingID == "" || req.ChannelID == "" { - return svcerr.ErrCreateEntity + return apiutil.ErrMissingID } return nil } diff --git a/things/api/http/requests_test.go b/things/api/http/requests_test.go index 783e9070ee..368e7508cc 100644 --- a/things/api/http/requests_test.go +++ b/things/api/http/requests_test.go @@ -732,7 +732,7 @@ func TestConnectChannelThingRequestValidate(t *testing.T) { ChannelID: "", ThingID: validID, }, - err: svcerr.ErrCreateEntity, + err: apiutil.ErrMissingID, }, { desc: "empty thing id", @@ -741,7 +741,7 @@ func TestConnectChannelThingRequestValidate(t *testing.T) { ChannelID: validID, ThingID: "", }, - err: svcerr.ErrCreateEntity, + err: apiutil.ErrMissingID, }, } for _, c := range cases { @@ -772,7 +772,7 @@ func TestDisconnectChannelThingRequestValidate(t *testing.T) { ChannelID: "", ThingID: validID, }, - err: svcerr.ErrCreateEntity, + err: apiutil.ErrMissingID, }, { desc: "empty thing id", @@ -781,7 +781,7 @@ func TestDisconnectChannelThingRequestValidate(t *testing.T) { ChannelID: validID, ThingID: "", }, - err: svcerr.ErrCreateEntity, + err: apiutil.ErrMissingID, }, } for _, c := range cases {