meowlib/client/peer_test.go

30 lines
595 B
Go
Raw Normal View History

2022-09-06 09:30:45 +02:00
package client
2022-01-15 22:19:29 +01:00
import (
2023-01-11 22:43:08 +01:00
"strconv"
2022-01-15 22:19:29 +01:00
"testing"
2023-01-11 22:43:08 +01:00
2024-05-28 16:47:04 +02:00
"github.com/google/uuid"
2023-01-11 22:43:08 +01:00
"github.com/stretchr/testify/assert"
2022-01-15 22:19:29 +01:00
)
func TestGetFromPublicKey(t *testing.T) {
2024-03-29 18:26:41 +01:00
id, err := CreateIdentity("test")
if err != nil {
t.Fatal("CreateIdentity failed")
}
id.Save()
2023-01-11 22:43:08 +01:00
for i := 1; i < 10; i++ {
var p Peer
2024-05-28 16:47:04 +02:00
p.Uid = uuid.New().String()
2023-01-11 22:43:08 +01:00
p.Name = "test" + strconv.Itoa(i)
2024-02-10 22:36:25 +01:00
p.ContactPublicKey = "stringToFind" + strconv.Itoa(i)
2024-05-28 16:47:04 +02:00
err := id.Peers.StorePeer(&p)
if err != nil {
t.Fatal("StorePeer failed")
}
2023-01-11 22:43:08 +01:00
}
p5 := id.Peers.GetFromPublicKey("stringToFind5")
assert.Equal(t, p5.Name, "test5")
2022-01-15 22:19:29 +01:00
}