You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
smug/options_test.go

47 lines
891 B
Go

4 years ago
package main
import (
"reflect"
"testing"
)
var usageTestTable = []struct {
argv []string
opts Options
}{
{
[]string{"start", "smug"},
Options{"start", "smug", []string{}, false, false},
4 years ago
},
{
[]string{"start", "smug", "-w", "foo"},
Options{"start", "smug", []string{"foo"}, false, false},
4 years ago
},
{
[]string{"start", "smug:foo,bar"},
Options{"start", "smug", []string{"foo", "bar"}, false, false},
},
{
[]string{"start", "smug", "--attach", "--debug"},
Options{"start", "smug", []string{}, true, true},
4 years ago
},
{
[]string{"start", "smug", "-ad"},
Options{"start", "smug", []string{}, true, true},
},
4 years ago
}
func TestParseOptions(t *testing.T) {
for _, v := range usageTestTable {
4 years ago
opts, err := ParseOptions(v.argv, func() {})
4 years ago
if err != nil {
t.Fail()
}
if !reflect.DeepEqual(v.opts, opts) {
t.Errorf("expected struct %v, got %v", v.opts, opts)
}
}
}