mirror of
https://github.com/tailscale/tailscale.git
synced 2024-11-25 11:05:45 +00:00
tka: fix go vet complaint on copy of lock value in tailchonk_test.go (#8208)
go vet complains when we copy a lock value. Create clone function that copies everything but the lock value. Fixes #8207 Signed-off-by: Val <valerie@tailscale.com>
This commit is contained in:
parent
cb94ddb7b8
commit
370b2c37e0
@ -8,6 +8,7 @@
|
|||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
"sync"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@ -620,6 +621,14 @@ func (c *compactingChonkFake) PurgeAUMs(hashes []AUMHash) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Avoid go vet complaining about copying a lock value
|
||||||
|
func cloneMem(src, dst *Mem) {
|
||||||
|
dst.l = sync.RWMutex{}
|
||||||
|
dst.aums = src.aums
|
||||||
|
dst.parentIndex = src.parentIndex
|
||||||
|
dst.lastActiveAncestor = src.lastActiveAncestor
|
||||||
|
}
|
||||||
|
|
||||||
func TestCompact(t *testing.T) {
|
func TestCompact(t *testing.T) {
|
||||||
fakeState := &State{
|
fakeState := &State{
|
||||||
Keys: []Key{{Kind: Key25519, Votes: 1}},
|
Keys: []Key{{Kind: Key25519, Votes: 1}},
|
||||||
@ -661,12 +670,13 @@ func TestCompact(t *testing.T) {
|
|||||||
`, optTemplate("checkpoint", AUM{MessageKind: AUMCheckpoint, State: fakeState}))
|
`, optTemplate("checkpoint", AUM{MessageKind: AUMCheckpoint, State: fakeState}))
|
||||||
|
|
||||||
storage := &compactingChonkFake{
|
storage := &compactingChonkFake{
|
||||||
Mem: (*c.Chonk().(*Mem)),
|
|
||||||
aumAge: map[AUMHash]time.Time{(c.AUMHashes["F1"]): time.Now()},
|
aumAge: map[AUMHash]time.Time{(c.AUMHashes["F1"]): time.Now()},
|
||||||
t: t,
|
t: t,
|
||||||
wantDelete: []AUMHash{c.AUMHashes["A"], c.AUMHashes["B"], c.AUMHashes["OLD"]},
|
wantDelete: []AUMHash{c.AUMHashes["A"], c.AUMHashes["B"], c.AUMHashes["OLD"]},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cloneMem(c.Chonk().(*Mem), &storage.Mem)
|
||||||
|
|
||||||
lastActiveAncestor, err := Compact(storage, c.AUMHashes["H"], CompactionOptions{MinChain: 2, MinAge: time.Hour})
|
lastActiveAncestor, err := Compact(storage, c.AUMHashes["H"], CompactionOptions{MinChain: 2, MinAge: time.Hour})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("Compact() failed: %v", err)
|
t.Errorf("Compact() failed: %v", err)
|
||||||
|
Loading…
Reference in New Issue
Block a user