2020-08-10 17:15:02 -04:00
|
|
|
// Copyright (c) HashiCorp, Inc.
|
2023-02-02 17:15:17 -08:00
|
|
|
// SPDX-License-Identifier: BUSL-1.1
|
|
|
|
|
|
2020-05-08 11:36:28 -04:00
|
|
|
package iam
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"testing"
|
|
|
|
|
|
2020-08-10 17:15:02 -04:00
|
|
|
"github.com/hashicorp/boundary/internal/types/action"
|
2020-05-08 11:36:28 -04:00
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
// Test_CrudActions provides unit tests for CrudActions()
|
|
|
|
|
func Test_CrudActions(t *testing.T) {
|
|
|
|
|
t.Parallel()
|
|
|
|
|
t.Run("valid", func(t *testing.T) {
|
2020-06-10 12:10:34 -04:00
|
|
|
assert := assert.New(t)
|
2020-05-08 11:36:28 -04:00
|
|
|
a := CrudlActions()
|
2020-06-26 11:00:14 -04:00
|
|
|
assert.Equal(a[action.Create.String()], action.Create)
|
|
|
|
|
assert.Equal(a[action.Update.String()], action.Update)
|
|
|
|
|
assert.Equal(a[action.Read.String()], action.Read)
|
|
|
|
|
assert.Equal(a[action.Delete.String()], action.Delete)
|
2020-05-08 11:36:28 -04:00
|
|
|
})
|
|
|
|
|
t.Run("invalid", func(t *testing.T) {
|
2020-06-10 12:10:34 -04:00
|
|
|
assert := assert.New(t)
|
2020-05-08 11:36:28 -04:00
|
|
|
a := CrudlActions()
|
2020-06-26 11:00:14 -04:00
|
|
|
aType, ok := a["invalid"]
|
2020-05-08 11:36:28 -04:00
|
|
|
assert.Equal(ok, false)
|
2020-06-26 11:00:14 -04:00
|
|
|
assert.Equal(aType, action.Unknown)
|
2020-05-08 11:36:28 -04:00
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Test_CrudlActions provides unit tests for CrudlActions()
|
|
|
|
|
func Test_CrudlActions(t *testing.T) {
|
|
|
|
|
t.Parallel()
|
|
|
|
|
t.Run("valid", func(t *testing.T) {
|
2020-06-10 12:10:34 -04:00
|
|
|
assert := assert.New(t)
|
2020-05-08 11:36:28 -04:00
|
|
|
a := CrudlActions()
|
2020-06-26 11:00:14 -04:00
|
|
|
assert.Equal(a[action.List.String()], action.List)
|
|
|
|
|
assert.Equal(a[action.Create.String()], action.Create)
|
|
|
|
|
assert.Equal(a[action.Update.String()], action.Update)
|
|
|
|
|
assert.Equal(a[action.Read.String()], action.Read)
|
|
|
|
|
assert.Equal(a[action.Delete.String()], action.Delete)
|
2020-05-08 11:36:28 -04:00
|
|
|
})
|
|
|
|
|
t.Run("invalid", func(t *testing.T) {
|
2020-06-10 12:10:34 -04:00
|
|
|
assert := assert.New(t)
|
2020-05-08 11:36:28 -04:00
|
|
|
a := CrudlActions()
|
2020-06-26 11:00:14 -04:00
|
|
|
aType, ok := a["invalid"]
|
2020-05-08 11:36:28 -04:00
|
|
|
assert.Equal(ok, false)
|
2020-06-26 11:00:14 -04:00
|
|
|
assert.Equal(aType, action.Unknown)
|
2020-05-08 11:36:28 -04:00
|
|
|
})
|
|
|
|
|
}
|