feat(prebuild): make prebuild available as an external package.

Usefull for downstream repo.
This commit is contained in:
Alexandre Pujol 2023-05-06 13:01:07 +01:00
parent 538da05696
commit 913ac3131c
No known key found for this signature in database
GPG key ID: C5469996F0DF68EC
13 changed files with 304 additions and 214 deletions

View file

@ -8,6 +8,8 @@ import (
"os"
"os/exec"
"testing"
"github.com/roddhjav/apparmor.d/pkg/prebuild"
)
func chdirGitRoot() {
@ -22,7 +24,7 @@ func chdirGitRoot() {
}
}
func Test_aaPrebuild(t *testing.T) {
func Test_AAPrebuild(t *testing.T) {
tests := []struct {
name string
wantErr bool
@ -58,20 +60,24 @@ func Test_aaPrebuild(t *testing.T) {
complain: true,
dist: "opensuse",
},
{
name: "Build for Fedora",
wantErr: true,
full: false,
complain: false,
dist: "fedora",
},
// {
// name: "Build for Fedora",
// wantErr: true,
// full: false,
// complain: false,
// dist: "fedora",
// },
}
chdirGitRoot()
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
Distribution = tt.dist
Complain = tt.complain
Full = tt.full
prebuild.Distribution = tt.dist
if tt.full {
prebuild.Prepares = append(prebuild.Prepares, prebuild.SetFullSystemPolicy)
}
if tt.complain {
prebuild.Builds = append(prebuild.Builds, prebuild.BuildComplain)
}
if err := aaPrebuild(); (err != nil) != tt.wantErr {
t.Errorf("aaPrebuild() error = %v, wantErr %v", err, tt.wantErr)
}