feat: publish standalone worker
Separate worker packaging and service lifecycle from the control plane.
Этот коммит содержится в:
56
spec/factories/contacts.go
Обычный файл
56
spec/factories/contacts.go
Обычный файл
@@ -0,0 +1,56 @@
|
||||
package factories
|
||||
|
||||
import (
|
||||
"github.com/icrowley/fake"
|
||||
|
||||
"rsgit.ru/rsmon/rsmon/app/models"
|
||||
)
|
||||
|
||||
// ContactFactory provides functionality.
|
||||
func ContactFactory(account *models.Account, user *models.User) models.Contact {
|
||||
contact := models.Contact{
|
||||
Name: fake.Company(),
|
||||
}
|
||||
if account == nil {
|
||||
c := AccountFactory()
|
||||
account = &c
|
||||
}
|
||||
contact.Account = account
|
||||
contact.AccountID = &account.ID
|
||||
|
||||
if user == nil {
|
||||
c := UserFactory()
|
||||
user = &c
|
||||
}
|
||||
contact.User = user
|
||||
contact.UserID = &user.ID
|
||||
|
||||
return contact
|
||||
}
|
||||
|
||||
// PersistedContact provides functionality.
|
||||
func PersistedContact(account *models.Account, user *models.User) models.Contact {
|
||||
contact := ContactFactory(account, user)
|
||||
|
||||
if contact.Account.ID == 0 {
|
||||
err := models.DB().Save(&contact.Account).Error
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
contact.AccountID = &contact.Account.ID
|
||||
}
|
||||
|
||||
if contact.User.ID == 0 {
|
||||
err := models.DB().Save(&contact.User).Error
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
contact.UserID = &contact.User.ID
|
||||
}
|
||||
|
||||
err := models.DB().Save(&contact).Error
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return contact
|
||||
}
|
||||
Ссылка в новой задаче
Block a user