From a19f95d9931bd99ae6212754347aab467c4081bc Mon Sep 17 00:00:00 2001 From: duwenxin Date: Tue, 10 Feb 2026 08:55:56 -0500 Subject: [PATCH] healthcare --- .../cloud_healthcare_integration_test.go | 61 ++++++++++--------- 1 file changed, 32 insertions(+), 29 deletions(-) diff --git a/tests/cloudhealthcare/cloud_healthcare_integration_test.go b/tests/cloudhealthcare/cloud_healthcare_integration_test.go index 72dac07928..4ffeee85d9 100644 --- a/tests/cloudhealthcare/cloud_healthcare_integration_test.go +++ b/tests/cloudhealthcare/cloud_healthcare_integration_test.go @@ -717,8 +717,8 @@ func runGetDatasetToolInvokeTest(t *testing.T, want string) { t.Run(tc.name, func(t *testing.T) { got, status := runTest(t, tc.api, tc.requestHeader, tc.requestBody) if tc.isErr { - if status == http.StatusOK { - t.Errorf("expected error but got success") + if status == http.StatusOK && !strings.Contains(got, "error") { + t.Errorf("expected error but got success: %s", got) } return } @@ -915,8 +915,8 @@ func runListDICOMStoresToolInvokeTest(t *testing.T, want string) { t.Run(tc.name, func(t *testing.T) { got, status := runTest(t, tc.api, tc.requestHeader, tc.requestBody) if tc.isErr { - if status == http.StatusOK { - t.Errorf("expected error but got success") + if status == http.StatusOK && !strings.Contains(got, "error") { + t.Errorf("expected error but got success: %s", got) } return } @@ -1021,8 +1021,8 @@ func runGetFHIRStoreToolInvokeTest(t *testing.T, fhirStoreID, want string) { t.Run(tc.name, func(t *testing.T) { got, status := runTest(t, tc.api, tc.requestHeader, tc.requestBody) if tc.isErr { - if status == http.StatusOK { - t.Errorf("expected error but got success") + if status == http.StatusOK && !strings.Contains(got, "error") { + t.Errorf("expected error but got success: %s", got) } return } @@ -1127,8 +1127,8 @@ func runGetFHIRStoreMetricsToolInvokeTest(t *testing.T, fhirStoreID, want string t.Run(tc.name, func(t *testing.T) { got, status := runTest(t, tc.api, tc.requestHeader, tc.requestBody) if tc.isErr { - if status == http.StatusOK { - t.Errorf("expected error but got success") + if status == http.StatusOK && !strings.Contains(got, "error") { + t.Errorf("expected error but got success: %s", got) } return } @@ -1240,8 +1240,8 @@ func runGetFHIRResourceToolInvokeTest(t *testing.T, storeID, resType, resID, wan t.Run(tc.name, func(t *testing.T) { got, status := runTest(t, tc.api, tc.requestHeader, tc.requestBody) if tc.isErr { - if status == http.StatusOK { - t.Errorf("expected error but got success") + if status == http.StatusOK && !strings.Contains(got, "error") { + t.Errorf("expected error but got success: %s", got) } return } @@ -1394,8 +1394,8 @@ func runFHIRPatientSearchToolInvokeTest(t *testing.T, fhirStoreID string, patien t.Run(tc.name, func(t *testing.T) { got, status := runTest(t, tc.api, tc.requestHeader, tc.requestBody) if tc.isErr { - if status == http.StatusOK { - t.Errorf("expected error but got success") + if status == http.StatusOK && !strings.Contains(got, "error") { + t.Errorf("expected error but got success: %s", got) } return } @@ -1531,8 +1531,8 @@ func runFHIRPatientEverythingToolInvokeTest(t *testing.T, fhirStoreID, patientID t.Run(tc.name, func(t *testing.T) { got, status := runTest(t, tc.api, tc.requestHeader, tc.requestBody) if tc.isErr { - if status == http.StatusOK { - t.Errorf("expected error but got success") + if status == http.StatusOK && !strings.Contains(got, "error") { + t.Errorf("expected error but got success: %s", got) } return } @@ -1637,8 +1637,8 @@ func runFHIRFetchPageToolInvokeTest(t *testing.T, pageURL, want string) { t.Run(tc.name, func(t *testing.T) { got, status := runTest(t, tc.api, tc.requestHeader, tc.requestBody) if tc.isErr { - if status == http.StatusOK { - t.Errorf("expected error but got success") + if status == http.StatusOK && !strings.Contains(got, "error") { + t.Errorf("expected error but got success: %s", got) } return } @@ -1710,6 +1710,9 @@ func runTest(t *testing.T, api string, requestHeader map[string]string, requestB got, ok := body["result"].(string) if !ok { + if errMsg, ok := body["error"].(string); ok { + return errMsg, http.StatusOK + } t.Fatalf("unable to find result in response body") } return got, http.StatusOK @@ -1837,8 +1840,8 @@ func runGetDICOMStoreToolInvokeTest(t *testing.T, dicomStoreID, want string) { t.Run(tc.name, func(t *testing.T) { got, status := runTest(t, tc.api, tc.requestHeader, tc.requestBody) if tc.isErr { - if status == http.StatusOK { - t.Errorf("expected error but got success") + if status == http.StatusOK && !strings.Contains(got, "error") { + t.Errorf("expected error but got success: %s", got) } return } @@ -1943,8 +1946,8 @@ func runGetDICOMStoreMetricsToolInvokeTest(t *testing.T, dicomStoreID, want stri t.Run(tc.name, func(t *testing.T) { got, status := runTest(t, tc.api, tc.requestHeader, tc.requestBody) if tc.isErr { - if status == http.StatusOK { - t.Errorf("expected error but got success") + if status == http.StatusOK && !strings.Contains(got, "error") { + t.Errorf("expected error but got success: %s", got) } return } @@ -2065,8 +2068,8 @@ func runSearchDICOMStudiesToolInvokeTest(t *testing.T, dicomStoreID string) { t.Run(tc.name, func(t *testing.T) { got, status := runTest(t, tc.api, tc.requestHeader, tc.requestBody) if tc.isErr { - if status == http.StatusOK { - t.Errorf("expected error but got success") + if status == http.StatusOK && !strings.Contains(got, "error") { + t.Errorf("expected error but got success: %s", got) } return } @@ -2187,8 +2190,8 @@ func runSearchDICOMSeriesToolInvokeTest(t *testing.T, dicomStoreID string) { t.Run(tc.name, func(t *testing.T) { got, status := runTest(t, tc.api, tc.requestHeader, tc.requestBody) if tc.isErr { - if status == http.StatusOK { - t.Errorf("expected error but got success") + if status == http.StatusOK && !strings.Contains(got, "error") { + t.Errorf("expected error but got success: %s", got) } return } @@ -2309,8 +2312,8 @@ func runSearchDICOMInstancesToolInvokeTest(t *testing.T, dicomStoreID string) { t.Run(tc.name, func(t *testing.T) { got, status := runTest(t, tc.api, tc.requestHeader, tc.requestBody) if tc.isErr { - if status == http.StatusOK { - t.Errorf("expected error but got success") + if status == http.StatusOK && !strings.Contains(got, "error") { + t.Errorf("expected error but got success: %s", got) } return } @@ -2422,10 +2425,10 @@ func runRetrieveRenderedDICOMInstanceToolInvokeTest(t *testing.T, dicomStoreID s } for _, tc := range invokeTcs { t.Run(tc.name, func(t *testing.T) { - _, status := runTest(t, tc.api, tc.requestHeader, tc.requestBody) + got, status := runTest(t, tc.api, tc.requestHeader, tc.requestBody) if tc.isErr { - if status == http.StatusOK { - t.Errorf("expected error but got success") + if status == http.StatusOK && !strings.Contains(got, "error") { + t.Errorf("expected error but got success: %s", got) } return }