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:
Stanislav Chzhen
2024-07-01 17:34:47 +03:00
parent 3993f4c476
commit 9d1c45fd94
11 changed files with 255 additions and 312 deletions

View File

@@ -4,6 +4,7 @@ import (
"net/netip"
"testing"
"github.com/AdguardTeam/golibs/container"
"github.com/AdguardTeam/golibs/testutil"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
@@ -126,13 +127,19 @@ func TestPersistent_EqualIDs(t *testing.T) {
}
func TestPersistent_Validate(t *testing.T) {
// TODO(s.chzhen): Add test cases.
const (
allowedTag = "allowed_tag"
notAllowedTag = "not_allowed_tag"
)
allowedTags := container.NewMapSet(allowedTag)
testCases := []struct {
name string
cli *Persistent
wantErrMsg string
}{{
name: "basic",
name: "success",
cli: &Persistent{
Name: "basic",
IPs: []netip.Addr{
@@ -162,11 +169,24 @@ func TestPersistent_Validate(t *testing.T) {
},
},
wantErrMsg: "uid required",
}, {
name: "not_allowed_tag",
cli: &Persistent{
Name: "basic",
IPs: []netip.Addr{
netip.MustParseAddr("1.2.3.4"),
},
UID: MustNewUID(),
Tags: []string{
notAllowedTag,
},
},
wantErrMsg: `invalid tag: "` + notAllowedTag + `"`,
}}
for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
err := tc.cli.validate(nil)
err := tc.cli.validate(allowedTags)
testutil.AssertErrorMsg(t, tc.wantErrMsg, err)
})
}