Skip to content

Commit

Permalink
test: test userdb lookup
Browse files Browse the repository at this point in the history
Signed-off-by: Djalal Harouni <[email protected]>
  • Loading branch information
tixxdz committed May 17, 2024
1 parent 706dffe commit c4dc849
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions pkg/reader/userdb/userdb_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// SPDX-License-Identifier: Apache-2.0
// Copyright Authors of Tetragon
//
// Lookup users from /etc/passwd

package userdb

import (
"testing"

"github.com/stretchr/testify/assert"
)

func TestUsersRecords(t *testing.T) {
name, err := UsersCache.lookupUser(0)
assert.Error(t, err)
assert.Empty(t, name)

UsersCache.addUser(0, "root")
name, err = UsersCache.lookupUser(0)
assert.NoError(t, err)
assert.Equal(t, "root", name)

name, err = UsersCache.LookupUser(2)
assert.NoError(t, err)
name2, err := UsersCache.lookupUser(2)
assert.NoError(t, err)
assert.Equal(t, name, name2)
}

0 comments on commit c4dc849

Please sign in to comment.