mirror of
https://github.com/roddhjav/apparmor.d.git
synced 2025-01-31 07:17:22 +01:00
fix(build): ensure tests work.
This commit is contained in:
parent
b88b8b8c26
commit
cf7ce9603e
7 changed files with 17 additions and 7 deletions
|
@ -6,10 +6,10 @@ package builder
|
|||
|
||||
import (
|
||||
"regexp"
|
||||
"slices"
|
||||
"strings"
|
||||
|
||||
"github.com/roddhjav/apparmor.d/pkg/prebuild/cfg"
|
||||
"golang.org/x/exp/slices"
|
||||
)
|
||||
|
||||
var (
|
||||
|
|
|
@ -5,8 +5,9 @@
|
|||
package builder
|
||||
|
||||
import (
|
||||
"slices"
|
||||
"testing"
|
||||
|
||||
"golang.org/x/exp/slices"
|
||||
)
|
||||
|
||||
func TestBuilder_Apply(t *testing.T) {
|
||||
|
|
|
@ -5,10 +5,10 @@
|
|||
package builder
|
||||
|
||||
import (
|
||||
"slices"
|
||||
"strings"
|
||||
|
||||
"github.com/roddhjav/apparmor.d/pkg/prebuild/cfg"
|
||||
"golang.org/x/exp/slices"
|
||||
)
|
||||
|
||||
type Enforce struct {
|
||||
|
|
|
@ -26,7 +26,7 @@ var (
|
|||
SystemdDir *paths.Path = paths.New("systemd")
|
||||
|
||||
// DebianDir is the directory where the debian specific files are stored
|
||||
DebianDir *paths.Path = DistDir.Join("debian")
|
||||
DebianDir *paths.Path = paths.New("debian")
|
||||
|
||||
// Either or not overwrite some upstreamed profile
|
||||
Overwrite = Overwriter{Enabled: false}
|
||||
|
|
|
@ -9,11 +9,18 @@ import (
|
|||
"os/exec"
|
||||
"testing"
|
||||
|
||||
"github.com/arduino/go-paths-helper"
|
||||
"github.com/roddhjav/apparmor.d/pkg/prebuild/builder"
|
||||
"github.com/roddhjav/apparmor.d/pkg/prebuild/cfg"
|
||||
"github.com/roddhjav/apparmor.d/pkg/prebuild/prepare"
|
||||
)
|
||||
|
||||
func setTestBuildDirectories(name string) {
|
||||
testRoot := paths.New("/tmp/tests")
|
||||
cfg.Root = testRoot.Join(name)
|
||||
cfg.RootApparmord = cfg.Root.Join("apparmor.d")
|
||||
}
|
||||
|
||||
func chdirGitRoot() {
|
||||
cmd := exec.Command("git", "rev-parse", "--show-toplevel")
|
||||
out, err := cmd.Output()
|
||||
|
@ -71,6 +78,7 @@ func Test_PreBuild(t *testing.T) {
|
|||
chdirGitRoot()
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
setTestBuildDirectories(tt.name)
|
||||
cfg.Distribution = tt.dist
|
||||
if tt.full {
|
||||
prepare.Register("fsp")
|
||||
|
|
|
@ -7,11 +7,11 @@ package prepare
|
|||
import (
|
||||
"os"
|
||||
"os/exec"
|
||||
"slices"
|
||||
"testing"
|
||||
|
||||
"github.com/arduino/go-paths-helper"
|
||||
"github.com/roddhjav/apparmor.d/pkg/prebuild/cfg"
|
||||
"golang.org/x/exp/slices"
|
||||
)
|
||||
|
||||
func chdirGitRoot() {
|
||||
|
@ -84,6 +84,7 @@ func TestTask_Apply(t *testing.T) {
|
|||
},
|
||||
}
|
||||
chdirGitRoot()
|
||||
cfg.Root.RemoveAll()
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
got, err := tt.task.Apply()
|
||||
|
|
|
@ -121,13 +121,13 @@ func TestCopyTo(t *testing.T) {
|
|||
{
|
||||
name: "default",
|
||||
src: paths.New("../../apparmor.d/groups/_full/"),
|
||||
dst: paths.New("../../.build/apparmor.d/groups/_full/"),
|
||||
dst: paths.New("/tmp/test/apparmor.d/groups/_full/"),
|
||||
wantErr: false,
|
||||
},
|
||||
{
|
||||
name: "issue-source",
|
||||
src: paths.New("../../apparmor.d/groups/nope/"),
|
||||
dst: paths.New("../../.build/apparmor.d/groups/_full/"),
|
||||
dst: paths.New("/tmp/test/apparmor.d/groups/_full/"),
|
||||
wantErr: true,
|
||||
},
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue