meowlib/client/peer_test.go

22 lines
435 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
"github.com/stretchr/testify/assert"
2022-01-15 22:19:29 +01:00
)
func TestGetFromPublicKey(t *testing.T) {
id := CreateIdentity("test")
id.Save()
2023-01-11 22:43:08 +01:00
for i := 1; i < 10; i++ {
var p Peer
p.Name = "test" + strconv.Itoa(i)
p.Contact.ContactPublicKey = "stringToFind" + strconv.Itoa(i)
id.Peers = append(id.Peers, p)
}
p5 := id.Peers.GetFromPublicKey("stringToFind5")
assert.Equal(t, p5.Name, "test5")
2022-01-15 22:19:29 +01:00
}