Skip to content

Commit

Permalink
NOISSUE - Add SDK Tests (#1812)
Browse files Browse the repository at this point in the history
* Add Things Tests

Signed-off-by: rodneyosodo <blackd0t@protonmail.com>

* Add Channel Tests

Signed-off-by: rodneyosodo <blackd0t@protonmail.com>

* Add Certs Tests

Signed-off-by: rodneyosodo <blackd0t@protonmail.com>

* Add Consumer Tests

Signed-off-by: rodneyosodo <blackd0t@protonmail.com>

* Enrich Group Tests

Signed-off-by: rodneyosodo <blackd0t@protonmail.com>

* Add Tests For Health

Signed-off-by: rodneyosodo <blackd0t@protonmail.com>

* Add Tests For Tokens

Signed-off-by: rodneyosodo <blackd0t@protonmail.com>

* Rename SDK for Tests

Signed-off-by: rodneyosodo <blackd0t@protonmail.com>

* Add Policies Tests

Signed-off-by: rodneyosodo <blackd0t@protonmail.com>

* Fix Linter

Signed-off-by: rodneyosodo <blackd0t@protonmail.com>

* Fix Tests

Signed-off-by: rodneyosodo <blackd0t@protonmail.com>

* Make Variable Defination Inline

Signed-off-by: rodneyosodo <blackd0t@protonmail.com>

---------

Signed-off-by: rodneyosodo <blackd0t@protonmail.com>
Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com>
  • Loading branch information
rodneyosodo authored and dborovcanin committed Jun 13, 2023
1 parent ca1c3eb commit 50561da
Show file tree
Hide file tree
Showing 25 changed files with 4,340 additions and 142 deletions.
2 changes: 1 addition & 1 deletion bootstrap/mocks/users.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func NewAuthClient(users map[string]string) policies.AuthServiceClient {
}

func (svc serviceMock) Identify(ctx context.Context, in *policies.Token, opts ...grpc.CallOption) (*policies.UserIdentity, error) {
if id, ok := svc.users[in.Value]; ok {
if id, ok := svc.users[in.GetValue()]; ok {
return &policies.UserIdentity{Id: id}, nil
}
return nil, errors.ErrAuthentication
Expand Down
4 changes: 2 additions & 2 deletions cli/channels.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,8 @@ var cmdChannels = []cobra.Command{
return
}
pm := mfxsdk.PageMetadata{
Offset: uint64(Offset),
Limit: uint64(Limit),
Offset: uint64(Offset),
Limit: uint64(Limit),
}
cl, err := sdk.ThingsByChannel(args[0], pm, args[1])
if err != nil {
Expand Down
4 changes: 2 additions & 2 deletions cli/things.go
Original file line number Diff line number Diff line change
Expand Up @@ -300,8 +300,8 @@ var cmdThings = []cobra.Command{
return
}
pm := mfxsdk.PageMetadata{
Offset: uint64(Offset),
Limit: uint64(Limit),
Offset: uint64(Offset),
Limit: uint64(Limit),
}
cl, err := sdk.ChannelsByThing(args[0], pm, args[1])
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion consumers/notifiers/api/endpoint_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@ func TestRemove(t *testing.T) {
desc: "remove not existing",
id: "not existing",
auth: token,
status: http.StatusNoContent,
status: http.StatusNotFound,
},
{
desc: "remove empty id",
Expand Down
3 changes: 3 additions & 0 deletions consumers/notifiers/mocks/subscriptions.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,9 @@ func appendSubs(subs []notifiers.Subscription, sub notifiers.Subscription, max i
func (srm *subRepoMock) Remove(_ context.Context, id string) error {
srm.mu.Lock()
defer srm.mu.Unlock()
if _, ok := srm.subs[id]; !ok {
return errors.ErrNotFound
}
delete(srm.subs, id)
return nil
}
2 changes: 1 addition & 1 deletion consumers/notifiers/service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ func TestRemoveSubscription(t *testing.T) {
desc: "test not existing",
token: exampleUser1,
id: "not_exist",
err: nil,
err: errors.ErrNotFound,
},
{
desc: "test with empty token",
Expand Down
Loading

0 comments on commit 50561da

Please sign in to comment.