tests: Backport RunUtilCompletion

Signed-off-by: Marek Siarkowicz <siarkowicz@google.com>
This commit is contained in:
Marek Siarkowicz
2023-03-16 13:53:17 +01:00
parent 00e1e5db21
commit 2eeb26083f
2 changed files with 20 additions and 0 deletions

View File

@@ -78,6 +78,21 @@ func spawnWithExpectLines(args []string, envVars map[string]string, xs ...string
return lines, perr
}
func runUtilCompletion(args []string, envVars map[string]string) ([]string, error) {
proc, err := spawnCmd(args, envVars)
if err != nil {
return nil, fmt.Errorf("failed to spawn command %v with error: %w", args, err)
}
proc.Wait()
err = proc.Close()
if err != nil {
return nil, fmt.Errorf("failed to close command %v with error: %w", args, err)
}
return proc.Lines(), nil
}
func randomLeaseID() int64 {
return rand.New(rand.NewSource(time.Now().UnixNano())).Int63()
}