Pull request 2255: 4923 Fix tests
Updates #4923. Squashed commit of the following: commit064d4aa30b
Author: Eugene Burkov <E.Burkov@AdGuard.COM> Date: Tue Jul 9 20:51:41 2024 +0300 dhcpsvc: close db commitd08b70983d
Author: Eugene Burkov <E.Burkov@AdGuard.COM> Date: Tue Jul 9 20:37:42 2024 +0300 dhcpsvc: fix test paths
This commit is contained in:
parent
e269260fbe
commit
130560b104
|
@ -106,6 +106,9 @@ func (srv *DHCPServer) dbLoad(ctx context.Context) (err error) {
|
|||
|
||||
return nil
|
||||
}
|
||||
defer func() {
|
||||
err = errors.WithDeferred(err, file.Close())
|
||||
}()
|
||||
|
||||
dl := &dataLeases{}
|
||||
err = json.NewDecoder(file).Decode(dl)
|
||||
|
|
|
@ -4,6 +4,7 @@ import (
|
|||
"io/fs"
|
||||
"net/netip"
|
||||
"os"
|
||||
"path"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"testing"
|
||||
|
@ -19,14 +20,14 @@ import (
|
|||
var testdata = os.DirFS("testdata")
|
||||
|
||||
// newTempDB copies the leases database file located in the testdata FS, under
|
||||
// tb.Name()/leases.db, to a temporary directory and returns the path to the
|
||||
// tb.Name()/leases.json, to a temporary directory and returns the path to the
|
||||
// copied file.
|
||||
func newTempDB(tb testing.TB) (dst string) {
|
||||
tb.Helper()
|
||||
|
||||
const filename = "leases.json"
|
||||
|
||||
data, err := fs.ReadFile(testdata, filepath.Join(tb.Name(), filename))
|
||||
data, err := fs.ReadFile(testdata, path.Join(tb.Name(), filename))
|
||||
require.NoError(tb, err)
|
||||
|
||||
dst = filepath.Join(tb.TempDir(), filename)
|
||||
|
|
Loading…
Reference in New Issue