mirror of
https://github.com/gravitl/netmaker.git
synced 2024-11-15 14:20:25 +08:00
42 lines
1,006 B
Go
42 lines
1,006 B
Go
|
package pro
|
||
|
|
||
|
import (
|
||
|
"testing"
|
||
|
|
||
|
"github.com/gravitl/netmaker/models/promodels"
|
||
|
"github.com/stretchr/testify/assert"
|
||
|
)
|
||
|
|
||
|
func TestUserGroupLogic(t *testing.T) {
|
||
|
|
||
|
t.Run("User Groups initialized successfully", func(t *testing.T) {
|
||
|
err := InitializeGroups()
|
||
|
assert.Nil(t, err)
|
||
|
})
|
||
|
|
||
|
t.Run("Check for default group", func(t *testing.T) {
|
||
|
groups, err := GetUserGroups()
|
||
|
assert.Nil(t, err)
|
||
|
var hasdefault bool
|
||
|
for k := range groups {
|
||
|
if string(k) == DEFAULT_ALLOWED_GROUPS {
|
||
|
hasdefault = true
|
||
|
}
|
||
|
}
|
||
|
assert.True(t, hasdefault)
|
||
|
})
|
||
|
|
||
|
t.Run("User Groups created successfully", func(t *testing.T) {
|
||
|
err := InsertUserGroup(promodels.UserGroupName("group1"))
|
||
|
assert.Nil(t, err)
|
||
|
err = InsertUserGroup(promodels.UserGroupName("group2"))
|
||
|
assert.Nil(t, err)
|
||
|
})
|
||
|
|
||
|
t.Run("User Groups deleted successfully", func(t *testing.T) {
|
||
|
err := DeleteUserGroup(promodels.UserGroupName("group1"))
|
||
|
assert.Nil(t, err)
|
||
|
assert.False(t, DoesUserGroupExist(promodels.UserGroupName("group1")))
|
||
|
})
|
||
|
}
|