mirror of
https://github.com/signaller-matrix/signaller.git
synced 2024-11-22 02:12:20 +00:00
Add user ID test
This commit is contained in:
parent
89646b5a46
commit
b02c6f99ac
@ -1,7 +1,6 @@
|
|||||||
package memory
|
package memory
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"strings"
|
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/nxshock/signaller/internal/models/createroom"
|
"github.com/nxshock/signaller/internal/models/createroom"
|
||||||
@ -9,23 +8,6 @@ import (
|
|||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestRegisterUser(t *testing.T) {
|
|
||||||
backend := NewBackend("localhost")
|
|
||||||
|
|
||||||
var (
|
|
||||||
username = "user1"
|
|
||||||
password = "password1"
|
|
||||||
device = "device1"
|
|
||||||
)
|
|
||||||
|
|
||||||
user, token, err := backend.Register(username, password, device)
|
|
||||||
assert.Nil(t, err)
|
|
||||||
assert.Equal(t, username, user.Name())
|
|
||||||
assert.Equal(t, password, user.Password())
|
|
||||||
assert.NotEmpty(t, token)
|
|
||||||
assert.True(t, strings.HasSuffix(user.ID(), backend.hostname))
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestCreateRoom(t *testing.T) {
|
func TestCreateRoom(t *testing.T) {
|
||||||
backend := NewBackend("localhost")
|
backend := NewBackend("localhost")
|
||||||
|
|
||||||
|
37
internal/backends/memory/user_test.go
Normal file
37
internal/backends/memory/user_test.go
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
package memory
|
||||||
|
|
||||||
|
import (
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"github.com/stretchr/testify/assert"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestRegisterUser(t *testing.T) {
|
||||||
|
backend := NewBackend("localhost")
|
||||||
|
|
||||||
|
var (
|
||||||
|
username = "user1"
|
||||||
|
password = "password1"
|
||||||
|
device = "device1"
|
||||||
|
)
|
||||||
|
|
||||||
|
user, token, err := backend.Register(username, password, device)
|
||||||
|
assert.Nil(t, err)
|
||||||
|
assert.Equal(t, username, user.Name())
|
||||||
|
assert.Equal(t, password, user.Password())
|
||||||
|
assert.NotEmpty(t, token)
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestUserID(t *testing.T) {
|
||||||
|
var (
|
||||||
|
userName = "user1"
|
||||||
|
hostName = "localhost"
|
||||||
|
expectedUserID = "@user1:localhost"
|
||||||
|
)
|
||||||
|
|
||||||
|
backend := NewBackend(hostName)
|
||||||
|
user, _, err := backend.Register(userName, "", "")
|
||||||
|
assert.Nil(t, err)
|
||||||
|
|
||||||
|
assert.Equal(t, expectedUserID, user.ID())
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user