2022-11-17 20:25:35 +01:00
|
|
|
package store
|
2022-11-17 20:41:07 +01:00
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
"testing"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestPublicFrontend(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)
|
|
|
|
|
|
|
|
feName := "public"
|
|
|
|
feId, err := str.CreateFrontend(envId, &Frontend{
|
2022-11-30 17:52:48 +01:00
|
|
|
Token: "token",
|
2022-11-28 19:55:53 +01:00
|
|
|
ZId: "zId0",
|
|
|
|
PublicName: &feName,
|
2022-11-17 20:41:07 +01:00
|
|
|
}, tx)
|
|
|
|
assert.Nil(t, err)
|
|
|
|
|
|
|
|
fe, err := str.GetFrontend(feId, tx)
|
|
|
|
assert.Nil(t, err)
|
|
|
|
assert.NotNil(t, fe)
|
|
|
|
assert.Equal(t, envId, fe.EnvironmentId)
|
2022-11-28 19:55:53 +01:00
|
|
|
assert.Equal(t, feName, *fe.PublicName)
|
2022-11-17 20:41:07 +01:00
|
|
|
|
2022-11-28 19:55:53 +01:00
|
|
|
fe0, err := str.FindFrontendPubliclyNamed(feName, tx)
|
2022-11-17 20:41:07 +01:00
|
|
|
assert.Nil(t, err)
|
|
|
|
assert.NotNil(t, fe0)
|
|
|
|
assert.EqualValues(t, fe, fe0)
|
|
|
|
|
|
|
|
err = str.DeleteFrontend(fe.Id, tx)
|
|
|
|
assert.Nil(t, err)
|
|
|
|
|
|
|
|
fe0, err = str.FindFrontendNamed(feName, tx)
|
|
|
|
assert.NotNil(t, err)
|
|
|
|
assert.Nil(t, fe0)
|
|
|
|
|
|
|
|
fe0, err = str.GetFrontend(fe.Id, tx)
|
|
|
|
assert.NotNil(t, err)
|
|
|
|
assert.Nil(t, fe0)
|
|
|
|
}
|