feat(osi): 实现老年人自理能力查询(T-303)
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
package handler
|
||||
|
||||
import (
|
||||
"io"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestElderlySelfCareReturnsRawResponse(t *testing.T) {
|
||||
client, seenPath := newTestClient(t, `{"code":"01","message":"操作成功","data":[{"checkId":"LNR-1","jc":"1","zpfs":"100"}]}`)
|
||||
h := NewElderlyHandler(client)
|
||||
|
||||
req := httptest.NewRequest(http.MethodGet, "/api/elderly/self-care?idCard=TEST-ID&phrId=PHR-1", nil)
|
||||
rec := httptest.NewRecorder()
|
||||
h.SelfCare(rec, req)
|
||||
|
||||
if rec.Code != http.StatusOK {
|
||||
t.Fatalf("status = %d", rec.Code)
|
||||
}
|
||||
if *seenPath != "/osi/api/auto/lnr/query" {
|
||||
t.Fatalf("osi path = %q", *seenPath)
|
||||
}
|
||||
body, _ := io.ReadAll(rec.Body)
|
||||
if !strings.Contains(string(body), `"zpfs":"100"`) {
|
||||
t.Fatalf("body missing assessment content: %s", body)
|
||||
}
|
||||
}
|
||||
|
||||
func TestElderlySelfCareRequiresIDCard(t *testing.T) {
|
||||
h := NewElderlyHandler(nil)
|
||||
req := httptest.NewRequest(http.MethodGet, "/api/elderly/self-care?phrId=PHR-1", nil)
|
||||
rec := httptest.NewRecorder()
|
||||
h.SelfCare(rec, req)
|
||||
|
||||
if rec.Code != http.StatusBadRequest {
|
||||
t.Fatalf("status = %d, want 400", rec.Code)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user