follow sql schema
This commit is contained in:
+8
-3
@@ -1,9 +1,10 @@
|
||||
package node
|
||||
|
||||
import (
|
||||
"mediarr/auth"
|
||||
"mediarr/cluster"
|
||||
"mediarr/database"
|
||||
"mediarr/user"
|
||||
"mediarr/identity"
|
||||
)
|
||||
|
||||
type Node struct {
|
||||
@@ -51,6 +52,10 @@ func (n *Node) ClusterIdentity() cluster.Identity {
|
||||
return n.cluster
|
||||
}
|
||||
|
||||
func (n *Node) Users() *user.Service {
|
||||
return user.NewService(n.db)
|
||||
func (n *Node) Identity() *identity.Service {
|
||||
return identity.NewService(n.db)
|
||||
}
|
||||
|
||||
func (n *Node) Auth() *auth.Service {
|
||||
return auth.NewService(n.db)
|
||||
}
|
||||
|
||||
@@ -4,30 +4,34 @@ import (
|
||||
"context"
|
||||
"testing"
|
||||
|
||||
"mediarr/user"
|
||||
"mediarr/auth"
|
||||
)
|
||||
|
||||
func TestNodeUsers(t *testing.T) {
|
||||
func TestNodeAuth(t *testing.T) {
|
||||
t.Chdir(t.TempDir())
|
||||
|
||||
err, node := NewNode(NewNodeParams{DatabaseName: "users"})
|
||||
if err != nil {
|
||||
t.Fatalf("NewNode : %v", err)
|
||||
}
|
||||
t.Cleanup(func() { _ = node.Close() })
|
||||
t.Cleanup(func() {
|
||||
if err := node.Close(); err != nil {
|
||||
t.Errorf("Close : %v", err)
|
||||
}
|
||||
})
|
||||
|
||||
if err := node.Up(); err != nil {
|
||||
t.Fatalf("Up : %v", err)
|
||||
}
|
||||
|
||||
created, err := node.Users().CreateUser(context.Background(), user.CreateUserParams{
|
||||
created, err := node.Auth().CreateUser(context.Background(), auth.CreateUserParams{
|
||||
Login: "alice",
|
||||
Password: "correct horse battery staple",
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatalf("CreateUser : %v", err)
|
||||
}
|
||||
if created.Login != "alice" {
|
||||
t.Fatalf("login = %q, attendu alice", created.Login)
|
||||
if created.Account.Login != "alice" {
|
||||
t.Fatalf("login = %q, attendu alice", created.Account.Login)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user