34 lines
584 B
Go
34 lines
584 B
Go
package client
|
|
|
|
import (
|
|
"log"
|
|
"testing"
|
|
|
|
"forge.redroom.link/yves/meowlib"
|
|
)
|
|
|
|
func TestStoreServer(t *testing.T) {
|
|
GetConfig().SetMemPass("test")
|
|
ss := ServerStorage{DbFile: "test.db"}
|
|
srv := Server{
|
|
Name: "test",
|
|
Url: "http://127.0.0.1",
|
|
PublicKey: meowlib.NewKeyPair().Public,
|
|
}
|
|
err := ss.StoreServer(&srv)
|
|
if err != nil {
|
|
log.Fatal(err)
|
|
}
|
|
sout, err := ss.LoadServer(srv.GetServerCard().GetUid())
|
|
if err != nil {
|
|
log.Fatal(err)
|
|
}
|
|
if sout == nil {
|
|
log.Fatal("server not found")
|
|
}
|
|
if sout.Name != srv.Name {
|
|
log.Fatal("name not found")
|
|
}
|
|
|
|
}
|