meowlib/client/identity_test.go

42 lines
707 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 (
"log"
"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
)
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) {
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
}
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.")
if exists("test.id") {
os.Remove("test.id")
}
}
func TestCreate(t *testing.T) {
2022-01-15 22:19:29 +01:00
}