1
0
mirror of synced 2024-11-21 12:36:04 +03:00

fix lint problem and test unmarshal message webhook

This commit is contained in:
Суханов Данила 2024-02-12 14:55:05 +03:00
parent f1ce041219
commit 0a0de1f669
3 changed files with 19 additions and 21 deletions

View File

@ -9,16 +9,16 @@ import (
const mgClientCacheTTL = time.Hour * 1
var NegativeCapacity = errors.New("capacity cannot be less than 1")
var ErrNegativeCapacity = errors.New("capacity cannot be less than 1")
type MGClientPool struct {
cache *otter.CacheWithVariableTTL[string, *MgClient]
}
// NewMGClientPool initializes the client cache
// NewMGClientPool initializes the client cache.
func NewMGClientPool(capacity int) (*MGClientPool, error) {
if capacity <= 0 {
return nil, NegativeCapacity
return nil, ErrNegativeCapacity
}
cache, _ := otter.MustBuilder[string, *MgClient](capacity).WithVariableTTL().Build()

View File

@ -1,8 +1,9 @@
package v1
import (
"github.com/stretchr/testify/suite"
"testing"
"github.com/stretchr/testify/suite"
)
type StorageTest struct {
@ -26,5 +27,5 @@ func (t *StorageTest) Test_MGClientPool() {
func (t *StorageTest) Test_NegativeCapacity() {
_, err := NewMGClientPool(-1)
t.Assert().Equal(NegativeCapacity.Error(), err.Error())
t.Assert().Equal(ErrNegativeCapacity.Error(), err.Error())
}

View File

@ -306,22 +306,19 @@ func TestUnmarshalMessageWebhook(t *testing.T) {
},
"template": {
"code": "f87e678f_660b_461a_b60a_a6194e2e9094#thanks_for_order#ru",
"args": [
"8061C",
"17400"
],
"variables": {
"body": [
"8061C",
"17400"
],
"buttons": [
[],
[
"8061"
]
]
}
"variables": {
"body": {
"args": [
"8061C",
"17400"
]
},
"buttons": [{
"args": [
"8061"
]
}]
}
},
"attachments": {
"suggestions": [