Files
threshold/internal/session/ids_test.go
T
Jeff Mitchell b76b24a4ad Move prefixes for many packages into the globals package (#3069)
This is a prerequisite for some enhancements to grant validation
2023-03-10 15:06:39 -05:00

38 lines
909 B
Go

// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0
package session
import (
"strings"
"testing"
"github.com/hashicorp/boundary/globals"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func Test_Ids(t *testing.T) {
t.Parallel()
t.Run("s", func(t *testing.T) {
id, err := newId()
require.NoError(t, err)
assert.True(t, strings.HasPrefix(id, globals.SessionPrefix+"_"))
})
t.Run("ss", func(t *testing.T) {
id, err := newStateId()
require.NoError(t, err)
assert.True(t, strings.HasPrefix(id, StatePrefix+"_"))
})
t.Run("sc", func(t *testing.T) {
id, err := newConnectionId()
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+"_"))
})
}