add TestState with unit tests

pull/347/head
Jim Lambert 6 years ago
parent 807c203ef9
commit 82105b91c0

@ -19,6 +19,17 @@ import (
"github.com/stretchr/testify/require"
)
func TestState(t *testing.T, conn *gorm.DB, sessionId string, state Status) *State {
t.Helper()
require := require.New(t)
rw := db.New(conn)
s, err := NewState(sessionId, state)
require.NoError(err)
err = rw.Create(context.Background(), s)
require.NoError(err)
return s
}
func TestSession(
t *testing.T,
conn *gorm.DB,
@ -148,7 +159,7 @@ func TestSessionParams(t *testing.T, conn *gorm.DB, wrapper wrapping.Wrapper, ia
tcpTarget.PublicId,
sets[0].PublicId,
at.PublicId,
user.ScopeId, // for now, we pick the user scope as the session scope
tcpTarget.ScopeId,
"127.0.0.1",
"22"
}

@ -19,3 +19,17 @@ func Test_TestSession(t *testing.T) {
require.NotNil(s)
assert.NotEmpty(s.PublicId)
}
func Test_TestState(t *testing.T) {
t.Helper()
assert, require := assert.New(t), require.New(t)
conn, _ := db.TestSetup(t, "postgres")
wrapper := db.TestWrapper(t)
iamRepo := iam.TestRepo(t, conn, wrapper)
s := TestDefaultSession(t, conn, wrapper, iamRepo)
require.NotNil(s)
assert.NotEmpty(s.PublicId)
state := TestState(t, conn, s.PublicId, Pending)
require.NotNil(state)
}

Loading…
Cancel
Save