refractor: rename some path util function.

This commit is contained in:
Alexandre Pujol 2024-10-12 15:31:24 +01:00
parent ebdeef152c
commit 982c2c66aa
No known key found for this signature in database
GPG key ID: C5469996F0DF68EC
13 changed files with 87 additions and 82 deletions

View file

@ -10,7 +10,6 @@ import (
"testing"
"github.com/roddhjav/apparmor.d/pkg/paths"
"github.com/roddhjav/apparmor.d/pkg/util"
)
var (
@ -21,7 +20,7 @@ var (
// mustReadProfileFile read a file and return its content as a slice of string.
// It panics if an error occurs. It removes the last comment line.
func mustReadProfileFile(path *paths.Path) string {
res := strings.Split(util.MustReadFile(path), "\n")
res := strings.Split(path.MustReadFileAsString(), "\n")
return strings.Join(res[:len(res)-2], "\n")
}
@ -108,7 +107,7 @@ func TestAppArmorProfileFile_String(t *testing.T) {
},
}},
},
want: util.MustReadFile(testData.Join("string.aa")),
want: testData.Join("string.aa").MustReadFileAsString(),
},
}
for _, tt := range tests {

View file

@ -8,8 +8,6 @@ import (
"reflect"
"strings"
"testing"
"github.com/roddhjav/apparmor.d/pkg/util"
)
func Test_tokenizeRule(t *testing.T) {
@ -919,7 +917,7 @@ var (
},
{
name: "string.aa",
raw: util.MustReadFile(testData.Join("string.aa")),
raw: testData.Join("string.aa").MustReadFileAsString(),
apparmor: &AppArmorProfileFile{
Preamble: Rules{
&Comment{Base: Base{Comment: " Simple test profile for the AppArmorProfileFile.String() method", IsLineRule: true}},
@ -1017,7 +1015,7 @@ var (
},
{
name: "full.aa",
raw: util.MustReadFile(testData.Join("full.aa")),
raw: testData.Join("full.aa").MustReadFileAsString(),
apparmor: &AppArmorProfileFile{
Preamble: Rules{
&Comment{Base: Base{IsLineRule: true, Comment: " Simple test profile with all rules used"}},

View file

@ -10,7 +10,6 @@ import (
"strings"
"github.com/roddhjav/apparmor.d/pkg/paths"
"github.com/roddhjav/apparmor.d/pkg/util"
)
var (
@ -149,7 +148,7 @@ func (f *AppArmorProfileFile) resolveInclude(include *Include) error {
iFile := &AppArmorProfileFile{}
for _, file := range files {
raw, err := util.ReadFile(file)
raw, err := file.ReadFileAsString()
if err != nil {
return err
}