Skip to content

Commit

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

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 79aefef

Please sign in to comment.