build: define new unified build interfaces.
This commit is contained in:
parent
b6aed5cd8d
commit
62099d325d
2 changed files with 111 additions and 0 deletions
64
pkg/prebuild/cfg/core_test.go
Normal file
64
pkg/prebuild/cfg/core_test.go
Normal file
|
|
@ -0,0 +1,64 @@
|
|||
// apparmor.d - Full set of apparmor profiles
|
||||
// Copyright (C) 2021-2024 Alexandre Pujol <alexandre@pujol.io>
|
||||
// SPDX-License-Identifier: GPL-2.0-only
|
||||
|
||||
package cfg
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestBase_Helpers(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
b Base
|
||||
want string
|
||||
}{
|
||||
{
|
||||
name: "base",
|
||||
b: Base{Keyword: "test", Help: "test", Msg: "test"},
|
||||
want: "test",
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
if got := tt.b.Name(); got != tt.want {
|
||||
t.Errorf("Base.Name() = %v, want %v", got, tt.want)
|
||||
}
|
||||
if got := tt.b.Usage(); got != tt.want {
|
||||
t.Errorf("Base.Usage() = %v, want %v", got, tt.want)
|
||||
}
|
||||
if got := tt.b.Message(); got != tt.want {
|
||||
t.Errorf("Base.Message() = %v, want %v", got, tt.want)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestHelp(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
tasks map[string]Base
|
||||
want string
|
||||
}{
|
||||
{
|
||||
name: "one",
|
||||
tasks: map[string]Base{
|
||||
"one": {Keyword: "one", Help: "one", Msg: "one"},
|
||||
"two": {Keyword: "two", Help: "two", Msg: "two"},
|
||||
},
|
||||
want: `one`,
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
if got := Help(tt.name, tt.tasks); !strings.Contains(got, tt.want) {
|
||||
t.Errorf("Help() = %v, want %v", got, tt.want)
|
||||
}
|
||||
if got := Usage(tt.name, tt.tasks); !strings.Contains(got, tt.want) {
|
||||
t.Errorf("Usage() = %v, want %v", got, tt.want)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue