feat: publish standalone worker
Separate worker packaging and service lifecycle from the control plane.
Этот коммит содержится в:
60
app/models/check_settings_test.go
Обычный файл
60
app/models/check_settings_test.go
Обычный файл
@@ -0,0 +1,60 @@
|
||||
package models
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestCheckSettingsDistributed_Default(t *testing.T) {
|
||||
s := CheckSettings{}
|
||||
assert.False(t, s.Distributed, "new CheckSettings should default to Distributed=false")
|
||||
}
|
||||
|
||||
func TestCheckSettingsDistributed_JSON(t *testing.T) {
|
||||
original := CheckSettings{
|
||||
HTTPUsername: "user",
|
||||
HTTPPassword: "pass",
|
||||
ExpectedAnswer: "default",
|
||||
Timeout: 30,
|
||||
Distributed: true,
|
||||
}
|
||||
|
||||
data, err := json.Marshal(original)
|
||||
assert.NoError(t, err)
|
||||
assert.Contains(t, string(data), `"distributed":true`)
|
||||
|
||||
var decoded CheckSettings
|
||||
err = json.Unmarshal(data, &decoded)
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, original, decoded)
|
||||
assert.True(t, decoded.Distributed)
|
||||
}
|
||||
|
||||
func TestCheckSettingsDistributed_OmitFalse(t *testing.T) {
|
||||
s := CheckSettings{HTTPUsername: "user"}
|
||||
data, err := json.Marshal(s)
|
||||
assert.NoError(t, err)
|
||||
assert.Contains(t, string(data), `"distributed":false`)
|
||||
}
|
||||
|
||||
func TestCheckSettingsDistributed_CheckUnmarshal(t *testing.T) {
|
||||
c := &Check{
|
||||
Settings: []byte(`{"distributed": true, "timeout": 60}`),
|
||||
}
|
||||
got := c.GetSettings()
|
||||
assert.True(t, got.Distributed)
|
||||
assert.Equal(t, 60, got.Timeout)
|
||||
}
|
||||
|
||||
func TestPlanAllowsDistributed(t *testing.T) {
|
||||
var nilPlan *Plan
|
||||
assert.False(t, nilPlan.AllowsDistributed(), "nil plan must not allow distributed")
|
||||
|
||||
free := &Plan{Price: 0}
|
||||
assert.False(t, free.AllowsDistributed(), "free plan must not allow distributed")
|
||||
|
||||
paid := &Plan{Price: 100}
|
||||
assert.True(t, paid.AllowsDistributed(), "paid plan must allow distributed")
|
||||
}
|
||||
Ссылка в новой задаче
Block a user