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
|
||||
|
||||
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()
|
||||
|
@ -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())
|
||||
}
|
||||
|
@ -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": [
|
||||
|
Loading…
Reference in New Issue
Block a user