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