Pull request: use testutil

Squashed commit of the following:

commit 5345a14b3565f358c56a37500cafb35b7e397951
Author: Eugene Burkov <E.Burkov@AdGuard.COM>
Date:   Thu Oct 21 21:13:06 2021 +0300

    all: fix windows tests

commit 8b9cdbe3e78f43339d21277f04e686bb154f6968
Author: Eugene Burkov <E.Burkov@AdGuard.COM>
Date:   Thu Oct 21 20:23:55 2021 +0300

    all: imp code

commit 271fdbe74c29d8ea4b53d7f56d2a36612dfed7b3
Author: Eugene Burkov <E.Burkov@AdGuard.COM>
Date:   Thu Oct 21 19:43:32 2021 +0300

    all: imp testing

commit e340f9d48679c57fc8eb579b8b78d4957be111c4
Author: Eugene Burkov <E.Burkov@AdGuard.COM>
Date:   Thu Oct 21 18:53:51 2021 +0300

    all: use testutil
This commit is contained in:
Eugene Burkov
2021-10-22 11:58:18 +03:00
parent 7804d97743
commit ea8950a80d
29 changed files with 211 additions and 249 deletions

View File

@@ -8,6 +8,7 @@ import (
"testing"
"github.com/AdguardTeam/AdGuardHome/internal/aghtest"
"github.com/AdguardTeam/golibs/testutil"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
@@ -37,11 +38,12 @@ func TestStats(t *testing.T) {
}
s, err := createObject(conf)
require.Nil(t, err)
t.Cleanup(func() {
require.NoError(t, err)
testutil.CleanupAndRequireSuccess(t, func() (err error) {
s.clear()
s.Close()
assert.Nil(t, os.Remove(conf.Filename))
return os.Remove(conf.Filename)
})
s.Update(Entry{
@@ -109,10 +111,11 @@ func TestLargeNumbers(t *testing.T) {
UnitID: newID,
}
s, err := createObject(conf)
require.Nil(t, err)
t.Cleanup(func() {
require.NoError(t, err)
testutil.CleanupAndRequireSuccess(t, func() (err error) {
s.Close()
assert.Nil(t, os.Remove(conf.Filename))
return os.Remove(conf.Filename)
})
// Number of distinct clients and domains every hour.