mirror of
https://github.com/optim-enterprises-bv/vault.git
synced 2025-11-01 19:17:58 +00:00
Exit ScanView if context has been cancelled (#7419)
This commit is contained in:
@@ -34,6 +34,24 @@ func TestScanView(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestScanView_CancelContext(t *testing.T) {
|
||||
s := prepKeyStorage(t)
|
||||
|
||||
ctx, cancelCtx := context.WithCancel(context.Background())
|
||||
var i int
|
||||
err := ScanView(ctx, s, func(path string) {
|
||||
cancelCtx()
|
||||
i++
|
||||
})
|
||||
|
||||
if err == nil {
|
||||
t.Error("Want context cancel err, got none")
|
||||
}
|
||||
if i != 1 {
|
||||
t.Errorf("Want i==1, got %d", i)
|
||||
}
|
||||
}
|
||||
|
||||
func TestCollectKeys(t *testing.T) {
|
||||
s := prepKeyStorage(t)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user