meowlib/client/peer_test.go
ycc e674a0cb33
Some checks failed
continuous-integration/drone/push Build is failing
peers separate
2024-05-28 16:47:04 +02:00

30 lines
595 B
Go

package client
import (
"strconv"
"testing"
"github.com/google/uuid"
"github.com/stretchr/testify/assert"
)
func TestGetFromPublicKey(t *testing.T) {
id, err := CreateIdentity("test")
if err != nil {
t.Fatal("CreateIdentity failed")
}
id.Save()
for i := 1; i < 10; i++ {
var p Peer
p.Uid = uuid.New().String()
p.Name = "test" + strconv.Itoa(i)
p.ContactPublicKey = "stringToFind" + strconv.Itoa(i)
err := id.Peers.StorePeer(&p)
if err != nil {
t.Fatal("StorePeer failed")
}
}
p5 := id.Peers.GetFromPublicKey("stringToFind5")
assert.Equal(t, p5.Name, "test5")
}