dana-medical-site/internal/api/booking_providers_test.go
2026-10-22 07:40:00 +00:00

25 lines
788 B
Go

package api
import (
"net/http"
"net/http/httptest"
"strings"
"testing"
"dana/internal/storage"
)
func TestDoctorRejectsRemovedExternalBookingProvider(t *testing.T) {
app := &API{}
r := httptest.NewRequest(http.MethodPut, "/api/v1/admin/doctors/1", strings.NewReader(`{"last_name":"Тест","slug":"test","booking_provider":"medflex","medflex_user":"https://booking.medflex.ru/example"}`))
r.SetPathValue("id", "1")
w := httptest.NewRecorder()
app.adminUpdateDoctor(w, r, &storage.AdminUser{})
if w.Code != http.StatusUnprocessableEntity {
t.Fatalf("removed provider accepted: %d %s", w.Code, w.Body.String())
}
if len(bookingProviders) != 2 || !bookingProviders["native"] || !bookingProviders["none"] {
t.Fatal("only on-site appointment methods should remain")
}
}