2022-09-06 09:30:45 +02:00
|
|
|
package client
|
2022-01-15 22:19:29 +01:00
|
|
|
|
|
|
|
import (
|
|
|
|
"log"
|
2022-11-28 20:48:42 +01:00
|
|
|
"os"
|
2022-01-15 22:19:29 +01:00
|
|
|
"testing"
|
2022-09-02 12:07:21 +02:00
|
|
|
|
|
|
|
"github.com/stretchr/testify/assert"
|
2022-01-15 22:19:29 +01:00
|
|
|
)
|
|
|
|
|
2022-11-28 20:48:42 +01:00
|
|
|
func exists(filename string) bool {
|
|
|
|
if _, err := os.Stat(filename); err == nil {
|
|
|
|
return true
|
|
|
|
} else {
|
|
|
|
return false
|
|
|
|
}
|
2022-01-15 22:19:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
func TestLoad(t *testing.T) {
|
2022-11-28 20:48:42 +01:00
|
|
|
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")
|
2022-01-15 22:19:29 +01:00
|
|
|
if err != nil {
|
2022-09-02 12:07:21 +02:00
|
|
|
log.Println(err.Error())
|
2022-01-15 22:19:29 +01:00
|
|
|
}
|
2022-11-28 20:48:42 +01:00
|
|
|
assert.Equal(t, err, nil, "2nd Load error")
|
2022-09-02 12:07:21 +02:00
|
|
|
assert.Equal(t, id.Nickname, "myname", "The two words should be the same.")
|
2022-11-28 20:48:42 +01:00
|
|
|
if exists("test.id") {
|
|
|
|
os.Remove("test.id")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestCreate(t *testing.T) {
|
|
|
|
|
2022-01-15 22:19:29 +01:00
|
|
|
}
|