mirror of
https://git.mills.io/saltyim/saltyim.git
synced 2024-06-28 17:51:04 +00:00
![James Mills](/assets/img/avatar_default.png)
Co-authored-by: James Mills <prologic@shortcircuit.net.au> Reviewed-on: https://git.mills.io/saltyim/saltyim/pulls/55
34 lines
642 B
Go
34 lines
642 B
Go
package saltyim
|
|
|
|
import (
|
|
"io/ioutil"
|
|
"os"
|
|
"path/filepath"
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
const (
|
|
testAddr = "alice@example.com"
|
|
testIdentityPath = "alice.key"
|
|
)
|
|
|
|
func TestIdentity(t *testing.T) {
|
|
assert := assert.New(t)
|
|
require := require.New(t)
|
|
|
|
dir, err := ioutil.TempDir("", "salty")
|
|
require.NoError(err)
|
|
defer os.RemoveAll(dir)
|
|
|
|
addr, err := ParseAddr(testAddr)
|
|
require.NoError(err)
|
|
|
|
fn := filepath.Join(dir, testIdentityPath)
|
|
ident, err := CreateIdentity(WithIdentityAddr(addr), WithIdentityPath(fn))
|
|
require.NoError(err)
|
|
assert.NotNil(ident.Key())
|
|
}
|