Identity load and save params, invitation check
This commit is contained in:
@ -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) {
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user