fix lint problem and test unmarshal message webhook
This commit is contained in:
parent
f1ce041219
commit
0a0de1f669
@ -9,16 +9,16 @@ import (
|
|||||||
|
|
||||||
const mgClientCacheTTL = time.Hour * 1
|
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 {
|
type MGClientPool struct {
|
||||||
cache *otter.CacheWithVariableTTL[string, *MgClient]
|
cache *otter.CacheWithVariableTTL[string, *MgClient]
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewMGClientPool initializes the client cache
|
// NewMGClientPool initializes the client cache.
|
||||||
func NewMGClientPool(capacity int) (*MGClientPool, error) {
|
func NewMGClientPool(capacity int) (*MGClientPool, error) {
|
||||||
if capacity <= 0 {
|
if capacity <= 0 {
|
||||||
return nil, NegativeCapacity
|
return nil, ErrNegativeCapacity
|
||||||
}
|
}
|
||||||
|
|
||||||
cache, _ := otter.MustBuilder[string, *MgClient](capacity).WithVariableTTL().Build()
|
cache, _ := otter.MustBuilder[string, *MgClient](capacity).WithVariableTTL().Build()
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
package v1
|
package v1
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/stretchr/testify/suite"
|
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/stretchr/testify/suite"
|
||||||
)
|
)
|
||||||
|
|
||||||
type StorageTest struct {
|
type StorageTest struct {
|
||||||
@ -26,5 +27,5 @@ func (t *StorageTest) Test_MGClientPool() {
|
|||||||
|
|
||||||
func (t *StorageTest) Test_NegativeCapacity() {
|
func (t *StorageTest) Test_NegativeCapacity() {
|
||||||
_, err := NewMGClientPool(-1)
|
_, err := NewMGClientPool(-1)
|
||||||
t.Assert().Equal(NegativeCapacity.Error(), err.Error())
|
t.Assert().Equal(ErrNegativeCapacity.Error(), err.Error())
|
||||||
}
|
}
|
||||||
|
@ -306,22 +306,19 @@ func TestUnmarshalMessageWebhook(t *testing.T) {
|
|||||||
},
|
},
|
||||||
"template": {
|
"template": {
|
||||||
"code": "f87e678f_660b_461a_b60a_a6194e2e9094#thanks_for_order#ru",
|
"code": "f87e678f_660b_461a_b60a_a6194e2e9094#thanks_for_order#ru",
|
||||||
"args": [
|
"variables": {
|
||||||
"8061C",
|
"body": {
|
||||||
"17400"
|
"args": [
|
||||||
],
|
"8061C",
|
||||||
"variables": {
|
"17400"
|
||||||
"body": [
|
]
|
||||||
"8061C",
|
},
|
||||||
"17400"
|
"buttons": [{
|
||||||
],
|
"args": [
|
||||||
"buttons": [
|
"8061"
|
||||||
[],
|
]
|
||||||
[
|
}]
|
||||||
"8061"
|
}
|
||||||
]
|
|
||||||
]
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
"attachments": {
|
"attachments": {
|
||||||
"suggestions": [
|
"suggestions": [
|
||||||
|
Loading…
Reference in New Issue
Block a user