wand/config_test.go

45 lines
731 B
Go
Raw Normal View History

2025-08-24 01:45:25 +02:00
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"},
)
}