dispatch/pkg/letsencrypt/user_test.go

36 lines
604 B
Go
Raw Normal View History

2016-01-07 21:07:12 +00:00
package letsencrypt
import (
"io/ioutil"
"testing"
2016-03-01 00:51:26 +00:00
"github.com/stretchr/testify/assert"
2016-01-07 21:07:12 +00:00
)
func tempdir() string {
f, _ := ioutil.TempDir("", "")
return f
}
func testUser(t *testing.T, email string) {
user, err := newUser(email)
assert.Nil(t, err)
key := user.GetPrivateKey()
assert.NotNil(t, key)
err = saveUser(user)
assert.Nil(t, err)
user, err = getUser(email)
assert.Nil(t, err)
assert.Equal(t, email, user.GetEmail())
assert.Equal(t, key, user.GetPrivateKey())
}
func TestUser(t *testing.T) {
directory = Directory(tempdir())
testUser(t, "test@test.com")
testUser(t, "")
}