Identity load and save params, invitation check

This commit is contained in:
ycc
2022-11-28 20:48:42 +01:00
parent f4ebb5cab1
commit b464a855ae
6 changed files with 46 additions and 14 deletions

View File

@ -2,20 +2,40 @@ package client
import (
"log"
"os"
"testing"
"github.com/stretchr/testify/assert"
)
func TestCreate(t *testing.T) {
id := CreateIdentity("myname")
id.Save("test.id")
func exists(filename string) bool {
if _, err := os.Stat(filename); err == nil {
return true
} else {
return false
}
}
func TestLoad(t *testing.T) {
id, err := LoadIdentity("test.id")
if exists("test.id") {
os.Remove("test.id")
}
id, err := LoadIdentity("test.id", "toto")
if err != nil {
id := CreateIdentity("myname")
id.Save()
}
id, err = LoadIdentity("test.id", "toto")
if err != nil {
log.Println(err.Error())
}
assert.Equal(t, err, nil, "2nd Load error")
assert.Equal(t, id.Nickname, "myname", "The two words should be the same.")
if exists("test.id") {
os.Remove("test.id")
}
}
func TestCreate(t *testing.T) {
}