using log.Printf() instead of fmt.Printf()

This commit is contained in:
yuli
2024-08-06 16:53:23 +03:00
parent f9fb82edb8
commit 7cf2f3e2eb
8 changed files with 33 additions and 41 deletions

View File

@@ -2,6 +2,7 @@ package main
import (
"fmt"
"log"
"io/ioutil"
"net/http"
"net/http/httptest"
@@ -98,7 +99,7 @@ func TestUtilSMS(t *testing.T) {
rw.WriteHeader(200)
defer req.Body.Close()
bodyBytes, _ := ioutil.ReadAll(req.Body)
fmt.Printf("body: %s\n", string(bodyBytes))
log.Printf("body: %s\n", string(bodyBytes))
if string(bodyBytes) != "Body=Data+Bunker+code+1234&From=from1234&To=4444" {
t.Fatalf("bad request: %s", string(bodyBytes))
}
@@ -118,7 +119,7 @@ func TestUtilNotifyConsentChange(t *testing.T) {
rw.WriteHeader(200)
defer req.Body.Close()
bodyBytes, _ := ioutil.ReadAll(req.Body)
fmt.Printf("body: %s\n", string(bodyBytes))
log.Printf("body: %s\n", string(bodyBytes))
if string(bodyBytes) != `{"action":"consentchange","brief":"brief","identity":"user3@user3.com","mode":"email","status":"no"}` {
q <- fmt.Sprintf("bad request in notifyConsentChange: %s", string(bodyBytes))
} else {
@@ -141,7 +142,7 @@ func TestUtilNotifyProfileNew(t *testing.T) {
rw.WriteHeader(200)
defer req.Body.Close()
bodyBytes, _ := ioutil.ReadAll(req.Body)
fmt.Printf("body: %s\n", string(bodyBytes))
log.Printf("body: %s\n", string(bodyBytes))
if string(bodyBytes) != `{"action":"profilenew","identity":"user3@user3.com","mode":"email","profile":{"name":"alex"}}` {
q <- fmt.Sprintf("bad request in notifyConsentChange: %s", string(bodyBytes))
} else {
@@ -165,7 +166,7 @@ func TestUtilNotifyForgetMe(t *testing.T) {
rw.WriteHeader(200)
defer req.Body.Close()
bodyBytes, _ := ioutil.ReadAll(req.Body)
fmt.Printf("body: %s\n", string(bodyBytes))
log.Printf("body: %s\n", string(bodyBytes))
if string(bodyBytes) != `{"action":"forgetme","identity":"user3@user3.com","mode":"email","profile":{"name":"alex"}}` {
q <- fmt.Sprintf("bad request in notifyConsentChange: %s", string(bodyBytes))
} else {
@@ -189,7 +190,7 @@ func TestUtilNotifyProfileChange(t *testing.T) {
rw.WriteHeader(200)
defer req.Body.Close()
bodyBytes, _ := ioutil.ReadAll(req.Body)
fmt.Printf("body: %s\n", string(bodyBytes))
log.Printf("body: %s\n", string(bodyBytes))
if string(bodyBytes) != `{"action":"profilechange","identity":"user3@user3.com","mode":"email","old":{"name":"alex2"},"profile":{"name":"alex3"}}` {
q <- fmt.Sprintf("bad request in notifyConsentChange: %s", string(bodyBytes))
} else {