X-Git-Url: https://ruderich.org/simon/gitweb/?p=nsscash%2Fnsscash.git;a=blobdiff_plain;f=group_test.go;h=d5509b9a57695353e78c907a79d8d0058e48607a;hp=bc91eb3c3fe5838c25391f0276ae8b55baf539be;hb=bfa96c6bded3a8a4edab666f12429b0659e30ad2;hpb=06dfc130f0f152ef11c3113f7237e822b3e45b5b diff --git a/group_test.go b/group_test.go index bc91eb3..d5509b9 100644 --- a/group_test.go +++ b/group_test.go @@ -16,6 +16,7 @@ package main import ( + "fmt" "reflect" "strings" "testing" @@ -25,10 +26,17 @@ func TestParseGroups(t *testing.T) { tests := []struct { data string exp []Group + err error }{ { "", nil, + nil, + }, + { + "root:x:0:", + nil, + fmt.Errorf("no newline in last line: \"root:x:0:\""), }, { "root:x:0:\n", @@ -40,6 +48,7 @@ func TestParseGroups(t *testing.T) { Members: nil, }, }, + nil, }, { "root:x:0:foo\n", @@ -53,6 +62,7 @@ func TestParseGroups(t *testing.T) { }, }, }, + nil, }, { "root:x:0:foo,bar\n", @@ -67,14 +77,15 @@ func TestParseGroups(t *testing.T) { }, }, }, + nil, }, } for n, tc := range tests { res, err := ParseGroups(strings.NewReader(tc.data)) - if err != nil { + if !reflect.DeepEqual(err, tc.err) { t.Errorf("%d: err = %v, want %v", - n, res, nil) + n, err, tc.err) } if !reflect.DeepEqual(res, tc.exp) { t.Errorf("%d: res = %v, want %v",