build(directive): support both liust & map.

This commit is contained in:
Alexandre Pujol 2024-03-23 17:41:10 +00:00
parent f81ceb9185
commit 88fcdd8c8e
No known key found for this signature in database
GPG key ID: C5469996F0DF68EC
10 changed files with 126 additions and 86 deletions

View file

@ -11,6 +11,32 @@ import (
"github.com/arduino/go-paths-helper"
)
func TestDirective_Usage(t *testing.T) {
tests := []struct {
name string
d Directive
wantMessage string
wantUsage string
}{
{
name: "empty",
d: Directives["stack"],
wantMessage: "Stack directive applied",
wantUsage: `#aa:stack profiles_name...`,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := tt.d.Usage(); got != tt.wantUsage {
t.Errorf("Directive.Usage() = %v, want %v", got, tt.wantUsage)
}
if got := tt.d.Message(); got != tt.wantMessage {
t.Errorf("Directive.Usage() = %v, want %v", got, tt.wantMessage)
}
})
}
}
func TestNewOption(t *testing.T) {
tests := []struct {
name string
@ -28,13 +54,14 @@ func TestNewOption(t *testing.T) {
},
want: &Option{
Name: "dbus",
Args: map[string]string{
ArgMap: map[string]string{
"bus": "system",
"name": "org.gnome.DisplayManager",
"own": "",
},
File: paths.New(""),
Raw: " #aa:dbus own bus=system name=org.gnome.DisplayManager",
ArgList: []string{"own", "bus=system", "name=org.gnome.DisplayManager"},
File: nil,
Raw: " #aa:dbus own bus=system name=org.gnome.DisplayManager",
},
},
{
@ -46,10 +73,11 @@ func TestNewOption(t *testing.T) {
"opensuse",
},
want: &Option{
Name: "only",
Args: map[string]string{"opensuse": ""},
File: paths.New(""),
Raw: " #aa:only opensuse",
Name: "only",
ArgMap: map[string]string{"opensuse": ""},
ArgList: []string{"opensuse"},
File: nil,
Raw: " #aa:only opensuse",
},
},
}