mirror of
https://github.com/openziti/zrok.git
synced 2024-12-28 09:38:53 +01:00
61 lines
1.3 KiB
Go
61 lines
1.3 KiB
Go
package store
|
|
|
|
import (
|
|
"github.com/stretchr/testify/assert"
|
|
"testing"
|
|
)
|
|
|
|
func TestEphemeralEnvironment(t *testing.T) {
|
|
str, err := Open(&Config{Path: ":memory:", Type: "sqlite3"})
|
|
assert.Nil(t, err)
|
|
assert.NotNil(t, str)
|
|
|
|
tx, err := str.Begin()
|
|
assert.Nil(t, err)
|
|
assert.NotNil(t, tx)
|
|
|
|
envId, err := str.CreateEphemeralEnvironment(&Environment{
|
|
Description: "description",
|
|
Host: "host",
|
|
Address: "address",
|
|
ZId: "zId0",
|
|
}, tx)
|
|
assert.Nil(t, err)
|
|
|
|
env, err := str.GetEnvironment(envId, tx)
|
|
assert.Nil(t, err)
|
|
assert.NotNil(t, env)
|
|
assert.Nil(t, env.AccountId)
|
|
}
|
|
|
|
func TestEnvironment(t *testing.T) {
|
|
str, err := Open(&Config{Path: ":memory:", Type: "sqlite3"})
|
|
assert.Nil(t, err)
|
|
assert.NotNil(t, str)
|
|
|
|
tx, err := str.Begin()
|
|
assert.Nil(t, err)
|
|
assert.NotNil(t, tx)
|
|
|
|
acctId, err := str.CreateAccount(&Account{
|
|
Email: "test@test.com",
|
|
Password: "password",
|
|
Token: "token",
|
|
}, tx)
|
|
assert.Nil(t, err)
|
|
|
|
envId, err := str.CreateEnvironment(acctId, &Environment{
|
|
Description: "description",
|
|
Host: "host",
|
|
Address: "address",
|
|
ZId: "zId0",
|
|
}, tx)
|
|
assert.Nil(t, err)
|
|
|
|
env, err := str.GetEnvironment(envId, tx)
|
|
assert.Nil(t, err)
|
|
assert.NotNil(t, env)
|
|
assert.NotNil(t, env.AccountId)
|
|
assert.Equal(t, acctId, *env.AccountId)
|
|
}
|