add newConnectionStateId with unit test

jimlambrt-session-basics
Jim Lambert 6 years ago
parent 76eda01d66
commit 93c3b6ad2e

@ -15,6 +15,9 @@ const (
// ConnectionPrefix for connection PK ids
ConnectionPrefix = "sc"
// ConnectionStatePrefix for connection state PK ids
ConnectionStatePrefix = "scs"
)
func newId() (string, error) {
@ -40,3 +43,11 @@ func newConnectionId() (string, error) {
}
return id, nil
}
func newConnectionStateId() (string, error) {
id, err := db.NewPublicId(ConnectionStatePrefix)
if err != nil {
return "", fmt.Errorf("new session connection state id: %w", err)
}
return id, nil
}

@ -25,4 +25,9 @@ func Test_Ids(t *testing.T) {
require.NoError(t, err)
assert.True(t, strings.HasPrefix(id, ConnectionPrefix+"_"))
})
t.Run("scs", func(t *testing.T) {
id, err := newConnectionStateId()
require.NoError(t, err)
assert.True(t, strings.HasPrefix(id, ConnectionStatePrefix+"_"))
})
}

Loading…
Cancel
Save