jx/internal/system/os_test.go

39 lines
684 B
Go
Raw Normal View History

2024-10-09 22:40:47 +00:00
// Copyright 2024 Matthew Rich <matthewrich.conf@gmail.com>. All rights reserved.
package system
import (
_ "context"
_ "encoding/json"
"github.com/stretchr/testify/assert"
_ "io"
_ "net/http"
_ "net/http/httptest"
_ "net/url"
_ "strings"
"testing"
)
func TestLookupUID(t *testing.T) {
uid, e := LookupUID("nobody")
assert.Nil(t, e)
assert.Equal(t, 65534, uid)
nuid, ne := LookupUID("10101")
assert.Error(t, ne, "user: unknonwn userid ", ne)
assert.Equal(t, 10101, nuid)
}
func TestLookupGID(t *testing.T) {
gid, e := LookupGID("adm")
assert.Nil(t, e)
assert.Equal(t, 4, gid)
ngid, ne := LookupGID("1001")
assert.Nil(t, ne)
assert.Equal(t, 1001, ngid)
}