jx/internal/resource/os_test.go

39 lines
686 B
Go
Raw Permalink Normal View History

2024-03-20 19:23:31 +00:00
// Copyright 2024 Matthew Rich <matthewrich.conf@gmail.com>. All rights reserved.
2024-05-24 05:11:51 +00:00
2024-03-20 16:15:27 +00:00
package resource
import (
2024-03-25 20:31:06 +00:00
_ "context"
_ "encoding/json"
"github.com/stretchr/testify/assert"
_ "io"
_ "net/http"
_ "net/http/httptest"
_ "net/url"
_ "strings"
"testing"
2024-03-20 16:15:27 +00:00
)
func TestLookupUID(t *testing.T) {
2024-03-25 20:31:06 +00:00
uid, e := LookupUID("nobody")
2024-03-20 16:15:27 +00:00
2024-04-18 00:07:12 +00:00
assert.Nil(t, e)
2024-03-25 20:31:06 +00:00
assert.Equal(t, 65534, uid)
2024-04-18 00:07:12 +00:00
2024-05-06 00:48:54 +00:00
nuid, ne := LookupUID("10101")
assert.Error(t, ne, "user: unknonwn userid ", ne)
assert.Equal(t, 10101, nuid)
2024-03-20 16:15:27 +00:00
}
func TestLookupGID(t *testing.T) {
2024-05-24 05:11:51 +00:00
gid, e := LookupGID("adm")
2024-03-20 16:15:27 +00:00
2024-04-18 00:07:12 +00:00
assert.Nil(t, e)
2024-05-24 05:11:51 +00:00
assert.Equal(t, 4, gid)
2024-03-20 16:15:27 +00:00
2024-04-18 00:07:12 +00:00
ngid, ne := LookupGID("1001")
assert.Nil(t, ne)
assert.Equal(t, 1001, ngid)
2024-03-20 16:15:27 +00:00
}