libcontainer: user: update tests for GetAdditionalGroups
Update the tests to use the test-friendly GetAdditionalGroups API, rather than making random files for no good reason. Signed-off-by: Aleksa Sarai <cyphar@cyphar.com>
This commit is contained in:
parent
85f722dea0
commit
14f271fe4c
|
@ -1,9 +1,7 @@
|
||||||
package user
|
package user
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
|
||||||
"reflect"
|
"reflect"
|
||||||
"sort"
|
"sort"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
@ -355,7 +353,7 @@ this is just some garbage data
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestGetAdditionalGroupsPath(t *testing.T) {
|
func TestGetAdditionalGroups(t *testing.T) {
|
||||||
const groupContent = `
|
const groupContent = `
|
||||||
root:x:0:root
|
root:x:0:root
|
||||||
adm:x:43:
|
adm:x:43:
|
||||||
|
@ -419,14 +417,9 @@ this is just some garbage data
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, test := range tests {
|
for _, test := range tests {
|
||||||
tmpFile, err := ioutil.TempFile("", "get-additional-groups-path")
|
group := strings.NewReader(groupContent)
|
||||||
if err != nil {
|
|
||||||
t.Error(err)
|
|
||||||
}
|
|
||||||
fmt.Fprint(tmpFile, groupContent)
|
|
||||||
tmpFile.Close()
|
|
||||||
|
|
||||||
gids, err := GetAdditionalGroupsPath(test.groups, tmpFile.Name())
|
gids, err := GetAdditionalGroups(test.groups, group)
|
||||||
if test.hasError && err == nil {
|
if test.hasError && err == nil {
|
||||||
t.Errorf("Parse(%#v) expects error but has none", test)
|
t.Errorf("Parse(%#v) expects error but has none", test)
|
||||||
continue
|
continue
|
||||||
|
|
Loading…
Reference in New Issue