meowlib/client/peer_test.go

25 lines
488 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) {
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
p.Name = "test" + strconv.Itoa(i)
2024-02-10 22:36:25 +01:00
p.ContactPublicKey = "stringToFind" + strconv.Itoa(i)
id.Peers = append(id.Peers, &p)
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
}