Make restore lock contention coverage independent of startup timing
This commit is contained in:
@@ -380,8 +380,19 @@ func TestExecuteRestoreLockConflictFailsAndWritesNothing(t *testing.T) {
|
||||
|
||||
deps := restoreCommandDependencies(fake)
|
||||
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 100*time.Millisecond)
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
defer cancel()
|
||||
discover := deps.discoverRemoteCurrentState
|
||||
if discover == nil {
|
||||
discover = discoverRemoteCurrentState
|
||||
}
|
||||
deps.discoverRemoteCurrentState = func(ctx context.Context, cfg *config.Config, store storage.ObjectStore) (*RemoteCurrentState, error) {
|
||||
current, err := discover(ctx, cfg, store)
|
||||
// Cancel after discovery so configuration and storage startup have no
|
||||
// incidental deadline. The held lock must prevent installation.
|
||||
cancel()
|
||||
return current, err
|
||||
}
|
||||
err = restoreWithDependencies(ctx, []string{"2026-05-03", "--config", pipelinePath, "--campaign-file", campaignPath, "--session", sessionPath}, &bytes.Buffer{}, deps)
|
||||
if err == nil || !strings.Contains(err.Error(), "acquire session lock") {
|
||||
t.Fatalf("Restore() error = %v, want lock failure", err)
|
||||
|
||||
Reference in New Issue
Block a user