Rework fakes to allow additional arguments
This commit is contained in:
parent
e7bb1e8df9
commit
a04f00234e
|
|
@ -19,10 +19,18 @@ func main() {
|
|||
"--storage-backend=etcd3",
|
||||
"--etcd-servers=the etcd url",
|
||||
}
|
||||
numExpectedArgs := len(expectedArgs)
|
||||
numGivenArgs := len(os.Args) - 1
|
||||
|
||||
for i, arg := range os.Args[1:] {
|
||||
if arg != expectedArgs[i] {
|
||||
fmt.Printf("Expected arg %s, got arg %s", expectedArgs[i], arg)
|
||||
if numGivenArgs < numExpectedArgs {
|
||||
fmt.Printf("Expected at least %d args, only got %d\n", numExpectedArgs, numGivenArgs)
|
||||
os.Exit(2)
|
||||
}
|
||||
|
||||
for i, arg := range expectedArgs {
|
||||
givenArg := os.Args[i+1]
|
||||
if arg != givenArg {
|
||||
fmt.Printf("Expected arg %s, got arg %s\n", arg, givenArg)
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,18 +8,25 @@ import (
|
|||
|
||||
func main() {
|
||||
expectedArgs := []string{
|
||||
"--debug",
|
||||
"--advertise-client-urls",
|
||||
"our etcd url",
|
||||
"--data-dir",
|
||||
"our data directory",
|
||||
"--listen-client-urls",
|
||||
"our etcd url",
|
||||
"--debug",
|
||||
"--data-dir",
|
||||
}
|
||||
numExpectedArgs := len(expectedArgs)
|
||||
numGivenArgs := len(os.Args) - 1
|
||||
|
||||
if numGivenArgs < numExpectedArgs {
|
||||
fmt.Printf("Expected at least %d args, only got %d\n", numExpectedArgs, numGivenArgs)
|
||||
os.Exit(2)
|
||||
}
|
||||
|
||||
for i, arg := range os.Args[1:] {
|
||||
if arg != expectedArgs[i] {
|
||||
fmt.Printf("Expected arg %s, got arg %s", expectedArgs[i], arg)
|
||||
for i, arg := range expectedArgs {
|
||||
givenArg := os.Args[i+1]
|
||||
if arg != givenArg {
|
||||
fmt.Printf("Expected arg %s, got arg %s\n", arg, givenArg)
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue