Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into upd-dnsproxy
Browse files Browse the repository at this point in the history
  • Loading branch information
Mizzick committed Jul 10, 2024
2 parents 3de6224 + 130560b commit 4638117
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
3 changes: 3 additions & 0 deletions internal/dhcpsvc/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
5 changes: 3 additions & 2 deletions internal/dhcpsvc/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"io/fs"
"net/netip"
"os"
"path"
"path/filepath"
"strings"
"testing"
Expand All @@ -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)
Expand Down

0 comments on commit 4638117

Please sign in to comment.