From 14f271fe4c0e5c17e7b0610ed352cca0b6f0e981 Mon Sep 17 00:00:00 2001 From: Aleksa Sarai Date: Sun, 28 Jun 2015 11:18:20 +1000 Subject: [PATCH] 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 --- libcontainer/user/user_test.go | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/libcontainer/user/user_test.go b/libcontainer/user/user_test.go index ffb0760e2..0e37ac3dd 100644 --- a/libcontainer/user/user_test.go +++ b/libcontainer/user/user_test.go @@ -1,9 +1,7 @@ package user import ( - "fmt" "io" - "io/ioutil" "reflect" "sort" "strconv" @@ -355,7 +353,7 @@ this is just some garbage data } } -func TestGetAdditionalGroupsPath(t *testing.T) { +func TestGetAdditionalGroups(t *testing.T) { const groupContent = ` root:x:0:root adm:x:43: @@ -419,14 +417,9 @@ this is just some garbage data } for _, test := range tests { - tmpFile, err := ioutil.TempFile("", "get-additional-groups-path") - if err != nil { - t.Error(err) - } - fmt.Fprint(tmpFile, groupContent) - tmpFile.Close() + group := strings.NewReader(groupContent) - gids, err := GetAdditionalGroupsPath(test.groups, tmpFile.Name()) + gids, err := GetAdditionalGroups(test.groups, group) if test.hasError && err == nil { t.Errorf("Parse(%#v) expects error but has none", test) continue