45 lines
731 B
Go
45 lines
731 B
Go
|
|
package wand
|
||
|
|
|
||
|
|
import (
|
||
|
|
"bytes"
|
||
|
|
"code.squareroundforest.org/arpio/notation"
|
||
|
|
"testing"
|
||
|
|
)
|
||
|
|
|
||
|
|
func TestConfig(t *testing.T) {
|
||
|
|
type options struct {
|
||
|
|
FooBarBaz int
|
||
|
|
Foo string
|
||
|
|
FooBar []string
|
||
|
|
}
|
||
|
|
|
||
|
|
impl := func(o options) {
|
||
|
|
if o.FooBarBaz != 42 {
|
||
|
|
t.Fatal(notation.Sprintw(o))
|
||
|
|
}
|
||
|
|
|
||
|
|
if o.Foo != "" {
|
||
|
|
t.Fatal(notation.Sprintw(o))
|
||
|
|
}
|
||
|
|
|
||
|
|
if len(o.FooBar) != 2 || o.FooBar[0] != "bar" || o.FooBar[1] != "baz" {
|
||
|
|
t.Fatal(notation.Sprintw(o))
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
stdin := bytes.NewBuffer(nil)
|
||
|
|
stdout := bytes.NewBuffer(nil)
|
||
|
|
stderr := bytes.NewBuffer(nil)
|
||
|
|
|
||
|
|
exec(
|
||
|
|
stdin,
|
||
|
|
stdout,
|
||
|
|
stderr,
|
||
|
|
func(int) {},
|
||
|
|
Command("test", impl),
|
||
|
|
SystemConfig(),
|
||
|
|
nil,
|
||
|
|
[]string{"test", "--config", "./internal/tests/config.ini"},
|
||
|
|
)
|
||
|
|
}
|