23 lines
835 B
Go
23 lines
835 B
Go
package storage
|
||
|
||
import (
|
||
"encoding/json"
|
||
"testing"
|
||
)
|
||
|
||
// Настройки, сохранённые до появления лимитов, получают значения лимитов по умолчанию.
|
||
func TestOldBookingSettingsKeepDefaultLimits(t *testing.T) {
|
||
out := DefaultBookingSettings
|
||
if err := json.Unmarshal([]byte(`{"phone_check":false,"autocancel_hours":12,"cancel_before_hours":2}`), &out); err != nil {
|
||
t.Fatal(err)
|
||
}
|
||
if out.AutoCancelHours != 12 || out.MaxPerDoctorDay != 3 || out.MaxPerHour != 10 || out.MaxActivePerPhone != 3 {
|
||
t.Errorf("слияние с умолчаниями: %+v", out)
|
||
}
|
||
out = DefaultBookingSettings
|
||
_ = json.Unmarshal([]byte(`{"max_per_doctor_day":0}`), &out)
|
||
if out.MaxPerDoctorDay != 0 {
|
||
t.Error("явный 0 должен выключать правило")
|
||
}
|
||
}
|