feat: publish standalone worker
Separate worker packaging and service lifecycle from the control plane.
Этот коммит содержится в:
58
app/models/group_test.go
Обычный файл
58
app/models/group_test.go
Обычный файл
@@ -0,0 +1,58 @@
|
||||
package models_test
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"rsgit.ru/rsmon/rsmon/app/models"
|
||||
)
|
||||
|
||||
// TestSystemGroups verifies that SystemGroups returns only groups with
|
||||
// is_system=true and ignores groups with is_system=false or nil.
|
||||
func TestSystemGroups(t *testing.T) {
|
||||
models.Drop()
|
||||
models.Migrate()
|
||||
|
||||
account := &models.Account{Name: "test-account"}
|
||||
require.NoError(t, models.DB().Create(account).Error)
|
||||
|
||||
trueVal, falseVal := true, false
|
||||
|
||||
systemGroup := &models.Group{
|
||||
AccountID: account.ID,
|
||||
Name: "system-internal",
|
||||
IsSystem: &trueVal,
|
||||
}
|
||||
regularGroup := &models.Group{
|
||||
AccountID: account.ID,
|
||||
Name: "regular",
|
||||
IsSystem: &falseVal,
|
||||
}
|
||||
nilSystemGroup := &models.Group{
|
||||
AccountID: account.ID,
|
||||
Name: "nil-system",
|
||||
}
|
||||
|
||||
require.NoError(t, models.DB().Create(systemGroup).Error)
|
||||
require.NoError(t, models.DB().Create(regularGroup).Error)
|
||||
require.NoError(t, models.DB().Create(nilSystemGroup).Error)
|
||||
|
||||
got, err := models.SystemGroups()
|
||||
require.NoError(t, err)
|
||||
|
||||
var ids []int64
|
||||
var names []string
|
||||
for _, g := range got {
|
||||
ids = append(ids, g.ID)
|
||||
names = append(names, g.Name)
|
||||
}
|
||||
|
||||
assert.Contains(t, names, "system-internal")
|
||||
assert.NotContains(t, names, "regular")
|
||||
assert.NotContains(t, names, "nil-system")
|
||||
assert.Contains(t, ids, systemGroup.ID)
|
||||
assert.NotContains(t, ids, regularGroup.ID)
|
||||
assert.NotContains(t, ids, nilSystemGroup.ID)
|
||||
}
|
||||
Ссылка в новой задаче
Block a user