From 25c2f64118d6272e8ce8a0b6afebefb6daaaa96d Mon Sep 17 00:00:00 2001 From: andrei <18027129+akurilov@users.noreply.github.com> Date: Sun, 6 Aug 2023 09:27:10 +0300 Subject: [PATCH] fix: usage constants --- api/client_test.go | 6 +++--- api/grpc/limits/service_test.go | 4 ++-- api/grpc/permits/service_test.go | 4 ++-- api/grpc/subject/encode.go | 4 ++-- api/grpc/subject/subject.pb.go | 32 ++++++++++++++++---------------- api/grpc/subject/subject.proto | 6 +++--- int_test.go | 4 ++-- model/usage/subject.go | 4 ++-- 8 files changed, 32 insertions(+), 32 deletions(-) diff --git a/api/client_test.go b/api/client_test.go index e989314..7ae5c4c 100644 --- a/api/client_test.go +++ b/api/client_test.go @@ -49,7 +49,7 @@ func TestClient_ReadUsage(t *testing.T) { }, "fail": { svcPermits: permits.NewServiceMock(), - subj: usage.SubjectPublishMessages, + subj: usage.SubjectPublishEvents, userId: "fail", err: permits.ErrInternal, }, @@ -92,7 +92,7 @@ func TestClient_ReadUsageLimit(t *testing.T) { }, "both group and user missing": { svcLimits: limits.NewServiceMock(), - subj: usage.SubjectPublishMessages, + subj: usage.SubjectPublishEvents, userId: "group_missing", }, "group present, user missing": { @@ -116,7 +116,7 @@ func TestClient_ReadUsageLimit(t *testing.T) { }, "fail": { svcLimits: limits.NewServiceMock(), - subj: usage.SubjectPublishMessages, + subj: usage.SubjectPublishEvents, userId: "fail", err: limits.ErrInternal, }, diff --git a/api/grpc/limits/service_test.go b/api/grpc/limits/service_test.go index e903fa7..780a192 100644 --- a/api/grpc/limits/service_test.go +++ b/api/grpc/limits/service_test.go @@ -19,7 +19,7 @@ func TestService_Get(t *testing.T) { }{ "ok": { userId: "user0", - subject: usage.SubjectPublishMessages, + subject: usage.SubjectPublishEvents, lim: usage.Limit{ Count: 1, UserId: "user0", @@ -37,7 +37,7 @@ func TestService_Get(t *testing.T) { }, "fail auth": { userId: "fail_auth", - subject: usage.SubjectPublishMessages, + subject: usage.SubjectPublishEvents, err: auth.ErrAuth, }, } diff --git a/api/grpc/permits/service_test.go b/api/grpc/permits/service_test.go index ad16b8e..87d2043 100644 --- a/api/grpc/permits/service_test.go +++ b/api/grpc/permits/service_test.go @@ -20,7 +20,7 @@ func TestService_GetUsage(t *testing.T) { }{ "ok": { userId: "user0", - subject: usage.SubjectPublishMessages, + subject: usage.SubjectPublishEvents, out: usage.Usage{ Count: 1, CountTotal: 2, @@ -39,7 +39,7 @@ func TestService_GetUsage(t *testing.T) { }, "fail auth": { userId: "fail_auth", - subject: usage.SubjectPublishMessages, + subject: usage.SubjectPublishEvents, err: auth.ErrAuth, }, } diff --git a/api/grpc/subject/encode.go b/api/grpc/subject/encode.go index 2525fae..c9547fd 100644 --- a/api/grpc/subject/encode.go +++ b/api/grpc/subject/encode.go @@ -10,10 +10,10 @@ var ErrInvalidSubject = errors.New("unrecognized subject") func Encode(src usage.Subject) (dst Subject, err error) { switch src { - case usage.SubjectPublishMessages: - dst = Subject_PublishMessages case usage.SubjectSubscriptions: dst = Subject_Subscriptions + case usage.SubjectPublishEvents: + dst = Subject_PublishEvents default: err = fmt.Errorf("%w: %s", ErrInvalidSubject, src) } diff --git a/api/grpc/subject/subject.pb.go b/api/grpc/subject/subject.pb.go index ed564e4..4ed983d 100644 --- a/api/grpc/subject/subject.pb.go +++ b/api/grpc/subject/subject.pb.go @@ -23,22 +23,22 @@ const ( type Subject int32 const ( - Subject_Undefined Subject = 0 - Subject_PublishMessages Subject = 1 - Subject_Subscriptions Subject = 2 + Subject_Undefined Subject = 0 + Subject_Subscriptions Subject = 1 + Subject_PublishEvents Subject = 2 ) // Enum value maps for Subject. var ( Subject_name = map[int32]string{ 0: "Undefined", - 1: "PublishMessages", - 2: "Subscriptions", + 1: "Subscriptions", + 2: "PublishEvents", } Subject_value = map[string]int32{ - "Undefined": 0, - "PublishMessages": 1, - "Subscriptions": 2, + "Undefined": 0, + "Subscriptions": 1, + "PublishEvents": 2, } ) @@ -75,15 +75,15 @@ var file_api_grpc_subject_subject_proto_rawDesc = []byte{ 0x0a, 0x1e, 0x61, 0x70, 0x69, 0x2f, 0x67, 0x72, 0x70, 0x63, 0x2f, 0x73, 0x75, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x2f, 0x73, 0x75, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x13, 0x61, 0x77, 0x61, 0x6b, 0x61, 0x72, 0x69, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x73, 0x75, - 0x62, 0x6a, 0x65, 0x63, 0x74, 0x2a, 0x40, 0x0a, 0x07, 0x53, 0x75, 0x62, 0x6a, 0x65, 0x63, 0x74, + 0x62, 0x6a, 0x65, 0x63, 0x74, 0x2a, 0x3e, 0x0a, 0x07, 0x53, 0x75, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x12, 0x0d, 0x0a, 0x09, 0x55, 0x6e, 0x64, 0x65, 0x66, 0x69, 0x6e, 0x65, 0x64, 0x10, 0x00, 0x12, - 0x13, 0x0a, 0x0f, 0x50, 0x75, 0x62, 0x6c, 0x69, 0x73, 0x68, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, - 0x65, 0x73, 0x10, 0x01, 0x12, 0x11, 0x0a, 0x0d, 0x53, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x70, - 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x10, 0x02, 0x42, 0x33, 0x5a, 0x31, 0x67, 0x69, 0x74, 0x68, 0x75, - 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x61, 0x77, 0x61, 0x6b, 0x61, 0x72, 0x69, 0x2f, 0x63, 0x6c, - 0x69, 0x65, 0x6e, 0x74, 0x2d, 0x73, 0x64, 0x6b, 0x2d, 0x67, 0x6f, 0x2f, 0x61, 0x70, 0x69, 0x2f, - 0x67, 0x72, 0x70, 0x63, 0x2f, 0x73, 0x75, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x62, 0x06, 0x70, 0x72, - 0x6f, 0x74, 0x6f, 0x33, + 0x11, 0x0a, 0x0d, 0x53, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, + 0x10, 0x01, 0x12, 0x11, 0x0a, 0x0d, 0x50, 0x75, 0x62, 0x6c, 0x69, 0x73, 0x68, 0x45, 0x76, 0x65, + 0x6e, 0x74, 0x73, 0x10, 0x02, 0x42, 0x33, 0x5a, 0x31, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, + 0x63, 0x6f, 0x6d, 0x2f, 0x61, 0x77, 0x61, 0x6b, 0x61, 0x72, 0x69, 0x2f, 0x63, 0x6c, 0x69, 0x65, + 0x6e, 0x74, 0x2d, 0x73, 0x64, 0x6b, 0x2d, 0x67, 0x6f, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x67, 0x72, + 0x70, 0x63, 0x2f, 0x73, 0x75, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x33, } var ( diff --git a/api/grpc/subject/subject.proto b/api/grpc/subject/subject.proto index 6b907e1..78cf9d7 100644 --- a/api/grpc/subject/subject.proto +++ b/api/grpc/subject/subject.proto @@ -6,6 +6,6 @@ option go_package = "github.com/awakari/client-sdk-go/api/grpc/subject"; enum Subject { Undefined = 0; - PublishMessages = 1; - Subscriptions = 2; -} \ No newline at end of file + Subscriptions = 1; + PublishEvents = 2; +} diff --git a/int_test.go b/int_test.go index c202178..4e1c2dd 100644 --- a/int_test.go +++ b/int_test.go @@ -91,7 +91,7 @@ func TestPublicApiUsage(t *testing.T) { // Get the initial Publish Messages API Usage var usagePubMsgsStart usage.Usage - usagePubMsgsStart, err = client.ReadUsage(ctx, userId, usage.SubjectPublishMessages) + usagePubMsgsStart, err = client.ReadUsage(ctx, userId, usage.SubjectPublishEvents) assert.Nil(t, err) // Write a Message @@ -132,7 +132,7 @@ func TestPublicApiUsage(t *testing.T) { // Check the Publish Messages API Usage change var usagePubMsgs usage.Usage - usagePubMsgs, err = client.ReadUsage(ctx, userId, usage.SubjectPublishMessages) + usagePubMsgs, err = client.ReadUsage(ctx, userId, usage.SubjectPublishEvents) assert.Nil(t, err) assert.Equal(t, usagePubMsgsStart.Count+1, usagePubMsgs.Count) assert.Equal(t, usagePubMsgsStart.CountTotal+1, usagePubMsgs.CountTotal) diff --git a/model/usage/subject.go b/model/usage/subject.go index 77032c7..64c8206 100644 --- a/model/usage/subject.go +++ b/model/usage/subject.go @@ -4,14 +4,14 @@ type Subject int const ( SubjectUndefined Subject = iota - SubjectPublishMessages SubjectSubscriptions + SubjectPublishEvents ) func (s Subject) String() string { return [...]string{ "SubjectUndefined", - "SubjectPublishMessages", "SubjectSubscriptions", + "SubjectPublishEvents", }[s] }