From 207809f649092841c41d6383023ad9594d12d712 Mon Sep 17 00:00:00 2001 From: Andy Lo-A-Foe Date: Sat, 28 Sep 2024 13:38:24 +0200 Subject: [PATCH] Fix more Write calls --- ai/inference/compute_target_service_test.go | 3 +-- ai/inference/job_service_test.go | 5 ++--- ai/inference/model_service_test.go | 5 ++--- cdl/study_service_test.go | 2 +- cdr/operations_r4_service_test.go | 2 +- cdr/operations_stu3_service_test.go | 2 +- cdr/tenant_r4_service_test.go | 2 +- cdr/tenant_stu3_service_test.go | 2 +- dicom/config_service_cdr_service_account_test.go | 5 ++--- dicom/config_service_fhir_store_test.go | 5 ++--- dicom/config_service_import_service_test.go | 5 ++--- dicom/config_service_object_stores_test.go | 5 ++--- dicom/config_service_query_retrieve_service_test.go | 5 ++--- dicom/config_service_remote_notes_test.go | 7 +++---- dicom/config_service_repositories_test.go | 7 +++---- iam/organizations_service_test.go | 2 +- notification/producer_service_test.go | 2 +- notification/subscriber_service_test.go | 2 +- notification/subscription_service_test.go | 4 ++-- notification/topic_service_test.go | 2 +- 20 files changed, 32 insertions(+), 42 deletions(-) diff --git a/ai/inference/compute_target_service_test.go b/ai/inference/compute_target_service_test.go index 90f982b1..e7e0fee1 100644 --- a/ai/inference/compute_target_service_test.go +++ b/ai/inference/compute_target_service_test.go @@ -2,7 +2,6 @@ package inference_test import ( "encoding/json" - "io" "net/http" "testing" @@ -62,7 +61,7 @@ func TestComputeTargetCRD(t *testing.T) { return } w.WriteHeader(http.StatusCreated) - _, _ = io.WriteString(w, string(resp)) + _, _ = w.Write(resp) default: w.WriteHeader(http.StatusNotImplemented) } diff --git a/ai/inference/job_service_test.go b/ai/inference/job_service_test.go index 898fb5bd..6d332445 100644 --- a/ai/inference/job_service_test.go +++ b/ai/inference/job_service_test.go @@ -2,7 +2,6 @@ package inference_test import ( "encoding/json" - "io" "net/http" "testing" @@ -52,7 +51,7 @@ func TestJobCRD(t *testing.T) { w.WriteHeader(http.StatusInternalServerError) return } - _, _ = io.WriteString(w, string(resp)) + _, _ = w.Write(resp) case http.MethodDelete: w.WriteHeader(http.StatusOK) default: @@ -78,7 +77,7 @@ func TestJobCRD(t *testing.T) { return } w.WriteHeader(http.StatusCreated) - _, _ = io.WriteString(w, string(resp)) + _, _ = w.Write(resp) default: w.WriteHeader(http.StatusNotImplemented) } diff --git a/ai/inference/model_service_test.go b/ai/inference/model_service_test.go index c28efafa..55461b54 100644 --- a/ai/inference/model_service_test.go +++ b/ai/inference/model_service_test.go @@ -2,7 +2,6 @@ package inference_test import ( "encoding/json" - "io" "net/http" "testing" @@ -49,7 +48,7 @@ func TestModelCRD(t *testing.T) { w.WriteHeader(http.StatusInternalServerError) return } - _, _ = io.WriteString(w, string(resp)) + _, _ = w.Write(resp) case http.MethodDelete: w.WriteHeader(http.StatusOK) default: @@ -75,7 +74,7 @@ func TestModelCRD(t *testing.T) { return } w.WriteHeader(http.StatusCreated) - _, _ = io.WriteString(w, string(resp)) + _, _ = w.Write(resp) default: w.WriteHeader(http.StatusNotImplemented) } diff --git a/cdl/study_service_test.go b/cdl/study_service_test.go index e30de610..fca06bad 100644 --- a/cdl/study_service_test.go +++ b/cdl/study_service_test.go @@ -71,7 +71,7 @@ func TestResearchStudiesCRD(t *testing.T) { w.WriteHeader(http.StatusInternalServerError) return } - _, _ = io.WriteString(w, string(resp)) + _, _ = w.Write(resp) case "GET": w.WriteHeader(http.StatusOK) _, _ = io.WriteString(w, `{ diff --git a/cdr/operations_r4_service_test.go b/cdr/operations_r4_service_test.go index 2b482fa6..2bb4e3b7 100644 --- a/cdr/operations_r4_service_test.go +++ b/cdr/operations_r4_service_test.go @@ -112,7 +112,7 @@ func TestR4PostOperation(t *testing.T) { return } w.WriteHeader(http.StatusCreated) - _, _ = io.WriteString(w, string(jsonOrg)) + _, _ = w.Write(jsonOrg) default: w.WriteHeader(http.StatusMethodNotAllowed) } diff --git a/cdr/operations_stu3_service_test.go b/cdr/operations_stu3_service_test.go index 8e9452e0..e5585b59 100644 --- a/cdr/operations_stu3_service_test.go +++ b/cdr/operations_stu3_service_test.go @@ -112,7 +112,7 @@ func TestPostOperation(t *testing.T) { return } w.WriteHeader(http.StatusCreated) - _, _ = io.WriteString(w, string(jsonOrg)) + _, _ = w.Write(jsonOrg) default: w.WriteHeader(http.StatusMethodNotAllowed) } diff --git a/cdr/tenant_r4_service_test.go b/cdr/tenant_r4_service_test.go index 88ed5038..b8ab9dcd 100644 --- a/cdr/tenant_r4_service_test.go +++ b/cdr/tenant_r4_service_test.go @@ -30,7 +30,7 @@ func TestR4TenantService(t *testing.T) { return } w.WriteHeader(http.StatusCreated) - _, _ = io.WriteString(w, string(body)) + _, _ = w.Write(body) case "GET": w.WriteHeader(http.StatusOK) _, _ = io.WriteString(w, `{ diff --git a/cdr/tenant_stu3_service_test.go b/cdr/tenant_stu3_service_test.go index 715af015..12edb7a9 100644 --- a/cdr/tenant_stu3_service_test.go +++ b/cdr/tenant_stu3_service_test.go @@ -31,7 +31,7 @@ func TestTenantService(t *testing.T) { return } w.WriteHeader(http.StatusCreated) - _, _ = io.WriteString(w, string(body)) + _, _ = w.Write(body) case "GET": w.WriteHeader(http.StatusOK) _, _ = io.WriteString(w, `{ diff --git a/dicom/config_service_cdr_service_account_test.go b/dicom/config_service_cdr_service_account_test.go index 48538ea3..6b6b06a2 100644 --- a/dicom/config_service_cdr_service_account_test.go +++ b/dicom/config_service_cdr_service_account_test.go @@ -2,7 +2,6 @@ package dicom_test import ( "encoding/json" - "io" "net/http" "testing" @@ -41,7 +40,7 @@ func TestCDRServiceAccountGetSet(t *testing.T) { w.WriteHeader(http.StatusInternalServerError) return } - _, _ = io.WriteString(w, string(resp)) + _, _ = w.Write(resp) case "GET": account := dicom.CDRServiceAccount{ ID: serviceAccountID, @@ -52,7 +51,7 @@ func TestCDRServiceAccountGetSet(t *testing.T) { return } w.WriteHeader(http.StatusOK) - _, _ = io.WriteString(w, string(resp)) + _, _ = w.Write(resp) default: w.WriteHeader(http.StatusMethodNotAllowed) } diff --git a/dicom/config_service_fhir_store_test.go b/dicom/config_service_fhir_store_test.go index 2bddcb0c..7985b973 100644 --- a/dicom/config_service_fhir_store_test.go +++ b/dicom/config_service_fhir_store_test.go @@ -2,7 +2,6 @@ package dicom_test import ( "encoding/json" - "io" "net/http" "testing" @@ -41,7 +40,7 @@ func TestFHIRStoreGetSet(t *testing.T) { w.WriteHeader(http.StatusInternalServerError) return } - _, _ = io.WriteString(w, string(resp)) + _, _ = w.Write(resp) case "GET": store := dicom.FHIRStore{ ID: storeID, @@ -52,7 +51,7 @@ func TestFHIRStoreGetSet(t *testing.T) { return } w.WriteHeader(http.StatusOK) - _, _ = io.WriteString(w, string(resp)) + _, _ = w.Write(resp) default: w.WriteHeader(http.StatusMethodNotAllowed) } diff --git a/dicom/config_service_import_service_test.go b/dicom/config_service_import_service_test.go index 15bfffa4..3f090b4f 100644 --- a/dicom/config_service_import_service_test.go +++ b/dicom/config_service_import_service_test.go @@ -2,7 +2,6 @@ package dicom_test import ( "encoding/json" - "io" "net/http" "testing" @@ -41,7 +40,7 @@ func TestImportServiceGetSet(t *testing.T) { w.WriteHeader(http.StatusInternalServerError) return } - _, _ = io.WriteString(w, string(resp)) + _, _ = w.Write(resp) case "GET": store := dicom.ImportService{ ID: serviceID, @@ -52,7 +51,7 @@ func TestImportServiceGetSet(t *testing.T) { return } w.WriteHeader(http.StatusOK) - _, _ = io.WriteString(w, string(resp)) + _, _ = w.Write(resp) default: w.WriteHeader(http.StatusMethodNotAllowed) } diff --git a/dicom/config_service_object_stores_test.go b/dicom/config_service_object_stores_test.go index 3bf80740..dc4a04af 100644 --- a/dicom/config_service_object_stores_test.go +++ b/dicom/config_service_object_stores_test.go @@ -2,7 +2,6 @@ package dicom_test import ( "encoding/json" - "io" "net/http" "testing" @@ -41,7 +40,7 @@ func TestObjectStoreCRUD(t *testing.T) { w.WriteHeader(http.StatusInternalServerError) return } - _, _ = io.WriteString(w, string(resp)) + _, _ = w.Write(resp) default: w.WriteHeader(http.StatusMethodNotAllowed) } @@ -66,7 +65,7 @@ func TestObjectStoreCRUD(t *testing.T) { return } w.WriteHeader(http.StatusOK) - _, _ = io.WriteString(w, string(resp)) + _, _ = w.Write(resp) case "DELETE": w.WriteHeader(http.StatusNoContent) default: diff --git a/dicom/config_service_query_retrieve_service_test.go b/dicom/config_service_query_retrieve_service_test.go index be2a7504..14c7c0aa 100644 --- a/dicom/config_service_query_retrieve_service_test.go +++ b/dicom/config_service_query_retrieve_service_test.go @@ -2,7 +2,6 @@ package dicom_test import ( "encoding/json" - "io" "net/http" "testing" @@ -41,7 +40,7 @@ func TestMoveServiceGetSet(t *testing.T) { w.WriteHeader(http.StatusInternalServerError) return } - _, _ = io.WriteString(w, string(resp)) + _, _ = w.Write(resp) case "GET": stores := []dicom.SCPConfig{ { @@ -55,7 +54,7 @@ func TestMoveServiceGetSet(t *testing.T) { return } w.WriteHeader(http.StatusOK) - _, _ = io.WriteString(w, string(resp)) + _, _ = w.Write(resp) default: w.WriteHeader(http.StatusMethodNotAllowed) } diff --git a/dicom/config_service_remote_notes_test.go b/dicom/config_service_remote_notes_test.go index 7decc05b..5e9587b8 100644 --- a/dicom/config_service_remote_notes_test.go +++ b/dicom/config_service_remote_notes_test.go @@ -2,7 +2,6 @@ package dicom_test import ( "encoding/json" - "io" "net/http" "testing" @@ -42,7 +41,7 @@ func TestRemoteNodesCRUD(t *testing.T) { w.WriteHeader(http.StatusInternalServerError) return } - _, _ = io.WriteString(w, string(resp)) + _, _ = w.Write(resp) case "GET": repos := []dicom.RemoteNode{ { @@ -60,7 +59,7 @@ func TestRemoteNodesCRUD(t *testing.T) { return } w.WriteHeader(http.StatusOK) - _, _ = io.WriteString(w, string(resp)) + _, _ = w.Write(resp) default: w.WriteHeader(http.StatusMethodNotAllowed) } @@ -80,7 +79,7 @@ func TestRemoteNodesCRUD(t *testing.T) { return } w.WriteHeader(http.StatusOK) - _, _ = io.WriteString(w, string(resp)) + _, _ = w.Write(resp) case "DELETE": w.WriteHeader(http.StatusNoContent) default: diff --git a/dicom/config_service_repositories_test.go b/dicom/config_service_repositories_test.go index 2f90f41f..e0aea115 100644 --- a/dicom/config_service_repositories_test.go +++ b/dicom/config_service_repositories_test.go @@ -2,7 +2,6 @@ package dicom_test import ( "encoding/json" - "io" "net/http" "testing" @@ -42,7 +41,7 @@ func TestRepositoriesCRUD(t *testing.T) { w.WriteHeader(http.StatusInternalServerError) return } - _, _ = io.WriteString(w, string(resp)) + _, _ = w.Write(resp) case "GET": repos := []dicom.Repository{ { @@ -57,7 +56,7 @@ func TestRepositoriesCRUD(t *testing.T) { return } w.WriteHeader(http.StatusOK) - _, _ = io.WriteString(w, string(resp)) + _, _ = w.Write(resp) default: w.WriteHeader(http.StatusMethodNotAllowed) } @@ -77,7 +76,7 @@ func TestRepositoriesCRUD(t *testing.T) { return } w.WriteHeader(http.StatusOK) - _, _ = io.WriteString(w, string(resp)) + _, _ = w.Write(resp) case "DELETE": w.WriteHeader(http.StatusNoContent) default: diff --git a/iam/organizations_service_test.go b/iam/organizations_service_test.go index d3630696..d290291c 100644 --- a/iam/organizations_service_test.go +++ b/iam/organizations_service_test.go @@ -182,7 +182,7 @@ func TestUpdateAndDeleteOrganization(t *testing.T) { } w.Header().Set("Content-Type", "application/json") w.WriteHeader(http.StatusOK) - _, _ = io.WriteString(w, string(responseBody)) + _, _ = w.Write(responseBody) case "DELETE": if r.Header.Get("If-Method") != "DELETE" { w.WriteHeader(http.StatusForbidden) diff --git a/notification/producer_service_test.go b/notification/producer_service_test.go index 693bb340..aac5009b 100644 --- a/notification/producer_service_test.go +++ b/notification/producer_service_test.go @@ -52,7 +52,7 @@ func TestProducersCRD(t *testing.T) { w.WriteHeader(http.StatusInternalServerError) return } - _, _ = io.WriteString(w, string(resp)) + _, _ = w.Write(resp) case "GET": w.WriteHeader(http.StatusOK) _, _ = io.WriteString(w, `{ diff --git a/notification/subscriber_service_test.go b/notification/subscriber_service_test.go index f3c4e9e3..48225ed2 100644 --- a/notification/subscriber_service_test.go +++ b/notification/subscriber_service_test.go @@ -52,7 +52,7 @@ func TestSubscribersCRD(t *testing.T) { w.WriteHeader(http.StatusInternalServerError) return } - _, _ = io.WriteString(w, string(resp)) + _, _ = w.Write(resp) case "GET": w.WriteHeader(http.StatusOK) _, _ = io.WriteString(w, `{ diff --git a/notification/subscription_service_test.go b/notification/subscription_service_test.go index ae531090..ccb14846 100644 --- a/notification/subscription_service_test.go +++ b/notification/subscription_service_test.go @@ -47,7 +47,7 @@ func TestSubscriptionCRD(t *testing.T) { w.WriteHeader(http.StatusInternalServerError) return } - _, _ = io.WriteString(w, string(resp)) + _, _ = w.Write(resp) case "GET": w.WriteHeader(http.StatusOK) _, _ = io.WriteString(w, `{ @@ -116,7 +116,7 @@ func TestSubscriptionCRD(t *testing.T) { return } w.WriteHeader(http.StatusCreated) - _, _ = io.WriteString(w, string(resp)) + _, _ = w.Write(resp) default: w.WriteHeader(http.StatusMethodNotAllowed) } diff --git a/notification/topic_service_test.go b/notification/topic_service_test.go index 05a4b2d5..07045ce6 100644 --- a/notification/topic_service_test.go +++ b/notification/topic_service_test.go @@ -50,7 +50,7 @@ func TestTopicCRUD(t *testing.T) { w.WriteHeader(http.StatusInternalServerError) return } - _, _ = io.WriteString(w, string(resp)) + _, _ = w.Write(resp) case "GET": w.WriteHeader(http.StatusOK) _, _ = io.WriteString(w, `{