mirror of
https://github.com/hrfee/jfa-go.git
synced 2024-12-23 01:20:11 +00:00
Harvey Tindall
73e985c45c
addded permissions get/set before realizing it already comes as part of the User object. Split User attributes that will be templated into UserTemplate struct, which User inherits. ApplyTemplateToUser takes a UserTemplate, while ModifyUser takes a plain map with some typed fields (display name and email, for now).
70 lines
1.4 KiB
Go
70 lines
1.4 KiB
Go
package jellyseerr
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/hrfee/jfa-go/common"
|
|
)
|
|
|
|
const (
|
|
API_KEY = "MTcyMjI2MDM2MTYyMzMxNDZkZmYyLTE4MzMtNDUyNy1hODJlLTI0MTZkZGUyMDg2Ng=="
|
|
URI = "http://localhost:5055"
|
|
PERM = 2097184
|
|
)
|
|
|
|
func client() *Jellyseerr {
|
|
return NewJellyseerr(URI, API_KEY, common.NewTimeoutHandler("Jellyseerr", URI, false))
|
|
}
|
|
|
|
func TestMe(t *testing.T) {
|
|
js := client()
|
|
u, err := js.Me()
|
|
if err != nil {
|
|
t.Fatalf("returned error %+v", err)
|
|
}
|
|
if u.ID < 0 {
|
|
t.Fatalf("returned no user %+v\n", u)
|
|
}
|
|
}
|
|
|
|
/* func TestImportFromJellyfin(t *testing.T) {
|
|
js := client()
|
|
list, err := js.ImportFromJellyfin("6b75e189efb744f583aa2e8e9cee41d3")
|
|
if err != nil {
|
|
t.Fatalf("returned error %+v", err)
|
|
}
|
|
if len(list) == 0 {
|
|
t.Fatalf("returned no users")
|
|
}
|
|
} */
|
|
|
|
func TestMustGetUser(t *testing.T) {
|
|
js := client()
|
|
u, err := js.MustGetUser("8c9d25c070d641cd8ad9cf825f622a16")
|
|
if err != nil {
|
|
t.Fatalf("returned error %+v", err)
|
|
}
|
|
if u.ID < 0 {
|
|
t.Fatalf("returned no users")
|
|
}
|
|
}
|
|
|
|
func TestSetPermissions(t *testing.T) {
|
|
js := client()
|
|
err := js.SetPermissions("6b75e189efb744f583aa2e8e9cee41d3", PERM)
|
|
if err != nil {
|
|
t.Fatalf("returned error %+v", err)
|
|
}
|
|
}
|
|
|
|
func TestGetPermissions(t *testing.T) {
|
|
js := client()
|
|
perm, err := js.GetPermissions("6b75e189efb744f583aa2e8e9cee41d3")
|
|
if err != nil {
|
|
t.Fatalf("returned error %+v", err)
|
|
}
|
|
if perm != PERM {
|
|
t.Fatalf("got unexpected perm code %d", perm)
|
|
}
|
|
}
|