2022-09-28 09:01:17 +02:00
|
|
|
package entity
|
2020-07-13 16:12:32 +02:00
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
2020-11-21 18:08:41 +01:00
|
|
|
|
|
|
|
"github.com/stretchr/testify/assert"
|
2020-07-13 16:12:32 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
func TestUIDs_String(t *testing.T) {
|
|
|
|
uid := UIDs{"dghjkfd", "dfgehrih"}
|
|
|
|
assert.Equal(t, "dghjkfd,dfgehrih", uid.String())
|
|
|
|
}
|
|
|
|
|
2020-12-31 12:34:06 +01:00
|
|
|
func TestUIDs_Join(t *testing.T) {
|
|
|
|
uid := UIDs{"dghjkfd", "dfgehrih"}
|
|
|
|
assert.Equal(t, "dghjkfd|dfgehrih", uid.Join("|"))
|
|
|
|
}
|
|
|
|
|
2020-07-13 16:12:32 +02:00
|
|
|
func TestData_HasShare(t *testing.T) {
|
2022-09-28 09:01:17 +02:00
|
|
|
data := SessionData{Shares: []string{"abc123", "def444"}}
|
2020-07-13 16:12:32 +02:00
|
|
|
assert.True(t, data.HasShare("def444"))
|
|
|
|
assert.False(t, data.HasShare("xxx"))
|
|
|
|
}
|
2023-08-07 16:27:41 +02:00
|
|
|
|
|
|
|
func TestSessionData_RedeemToken(t *testing.T) {
|
|
|
|
data := SessionData{Shares: []string{"abc123", "def444"}}
|
|
|
|
assert.True(t, data.HasShare("def444"))
|
2024-01-05 16:31:07 +01:00
|
|
|
assert.False(t, data.HasShare("as6sg6bxpogaaba8"))
|
2023-08-07 16:27:41 +02:00
|
|
|
data.RedeemToken("xxx")
|
|
|
|
assert.False(t, data.HasShare("xxx"))
|
|
|
|
data.RedeemToken("1jxf3jfn2k")
|
|
|
|
assert.True(t, data.HasShare("def444"))
|
2024-01-05 16:31:07 +01:00
|
|
|
assert.True(t, data.HasShare("as6sg6bxpogaaba8"))
|
2023-08-07 16:27:41 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
func TestSessionData_SharedUIDs(t *testing.T) {
|
|
|
|
data := SessionData{Shares: []string{"abc123", "def444"},
|
|
|
|
Tokens: []string{"5jxf3jfn2k"}}
|
|
|
|
assert.Equal(t, "abc123", data.SharedUIDs()[0])
|
|
|
|
data2 := SessionData{Shares: []string{},
|
|
|
|
Tokens: []string{"5jxf3jfn2k"}}
|
2024-01-05 16:31:07 +01:00
|
|
|
assert.Equal(t, "fs6sg6bw45bn0004", data2.SharedUIDs()[0])
|
2023-08-07 16:27:41 +02:00
|
|
|
|
|
|
|
}
|