Pull request 2244: AG-27492-client-storage-usage
Squashed commit of the following:
commit 46956d0f5a36fbcd2324125bcc146bdb57cb3f7e
Merge: 85ccad786 3993f4c47
Author: Stanislav Chzhen <s.chzhen@adguard.com>
Date: Mon Jul 1 16:11:59 2024 +0300
Merge branch 'master' into AG-27492-client-storage-usage
commit 85ccad7862a35cbebc935776ac057f6bb6cfc75f
Author: Stanislav Chzhen <s.chzhen@adguard.com>
Date: Fri Jun 28 18:05:37 2024 +0300
all: imp docs
commit e7043efcda32635b4260344f11b5a61b5120a9d2
Author: Stanislav Chzhen <s.chzhen@adguard.com>
Date: Thu Jun 27 20:10:26 2024 +0300
all: client storage usage
This commit is contained in:
@@ -11,12 +11,12 @@ import (
|
||||
|
||||
// newIDIndex is a helper function that returns a client index filled with
|
||||
// persistent clients from the m. It also generates a UID for each client.
|
||||
func newIDIndex(m []*Persistent) (ci *Index) {
|
||||
ci = NewIndex()
|
||||
func newIDIndex(m []*Persistent) (ci *index) {
|
||||
ci = newIndex()
|
||||
|
||||
for _, c := range m {
|
||||
c.UID = MustNewUID()
|
||||
ci.Add(c)
|
||||
ci.add(c)
|
||||
}
|
||||
|
||||
return ci
|
||||
@@ -110,7 +110,7 @@ func TestClientIndex_Find(t *testing.T) {
|
||||
for _, tc := range testCases {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
for _, id := range tc.ids {
|
||||
c, ok := ci.Find(id)
|
||||
c, ok := ci.find(id)
|
||||
require.True(t, ok)
|
||||
|
||||
assert.Equal(t, tc.want, c)
|
||||
@@ -119,7 +119,7 @@ func TestClientIndex_Find(t *testing.T) {
|
||||
}
|
||||
|
||||
t.Run("not_found", func(t *testing.T) {
|
||||
_, ok := ci.Find(cliIPNone)
|
||||
_, ok := ci.find(cliIPNone)
|
||||
assert.False(t, ok)
|
||||
})
|
||||
}
|
||||
@@ -171,11 +171,11 @@ func TestClientIndex_Clashes(t *testing.T) {
|
||||
clone := tc.client.ShallowClone()
|
||||
clone.UID = MustNewUID()
|
||||
|
||||
err := ci.Clashes(clone)
|
||||
err := ci.clashes(clone)
|
||||
require.Error(t, err)
|
||||
|
||||
ci.Delete(tc.client)
|
||||
err = ci.Clashes(clone)
|
||||
ci.remove(tc.client)
|
||||
err = ci.clashes(clone)
|
||||
require.NoError(t, err)
|
||||
})
|
||||
}
|
||||
@@ -293,7 +293,7 @@ func TestIndex_FindByIPWithoutZone(t *testing.T) {
|
||||
|
||||
for _, tc := range testCases {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
c := ci.FindByIPWithoutZone(tc.ip.WithZone(""))
|
||||
c := ci.findByIPWithoutZone(tc.ip.WithZone(""))
|
||||
require.Equal(t, tc.want, c)
|
||||
})
|
||||
}
|
||||
@@ -339,7 +339,7 @@ func TestClientIndex_RangeByName(t *testing.T) {
|
||||
ci := newIDIndex(tc.want)
|
||||
|
||||
var got []*Persistent
|
||||
ci.RangeByName(func(c *Persistent) (cont bool) {
|
||||
ci.rangeByName(func(c *Persistent) (cont bool) {
|
||||
got = append(got, c)
|
||||
|
||||
return true
|
||||
|
||||
Reference in New Issue
Block a user