Commit 9f56b662 authored by Sonja Happ's avatar Sonja Happ
Browse files

replace some fmt. calls with log. calls #17

parent de4ac7b9
......@@ -6,6 +6,7 @@ import (
"git.rwth-aachen.de/acs/public/villas/web-backend-go/database"
"github.com/streadway/amqp"
"github.com/tidwall/gjson"
"log"
"strings"
"time"
)
......@@ -102,7 +103,7 @@ func ConnectAMQP(uri string) error {
db := database.GetDB()
err = db.Where("UUID = ?", gjson.Get(content, "properties.uuid")).Find(sToBeUpdated).Error
if err != nil {
fmt.Println("AMQP: Unable to find simulator with UUID: ", gjson.Get(content, "properties.uuid"), " DB error message: ", err)
log.Println("AMQP: Unable to find simulator with UUID: ", gjson.Get(content, "properties.uuid"), " DB error message: ", err)
}
err = db.Model(&sToBeUpdated).Updates(map[string]interface{}{
......@@ -114,10 +115,10 @@ func ConnectAMQP(uri string) error {
"RawProperties": gjson.Get(content, "properties"),
}).Error
if err != nil {
fmt.Println("AMQP: Unable to update simulator in DB: ", err)
log.Println("AMQP: Unable to update simulator in DB: ", err)
}
fmt.Println("AMQP: Updated simulator with UUID ", gjson.Get(content, "properties.uuid"))
log.Println("AMQP: Updated simulator with UUID ", gjson.Get(content, "properties.uuid"))
}
}()
......@@ -155,7 +156,7 @@ func SendActionAMQP(action Action, uuid string) error {
}
func PingAMQP() error {
fmt.Println("AMQP: sending ping command to all simulators")
log.Println("AMQP: sending ping command to all simulators")
var a Action
a.Act = "ping"
......
......@@ -3,6 +3,7 @@ package database
import (
"fmt"
"github.com/jinzhu/gorm"
"log"
"os"
"testing"
......@@ -26,8 +27,7 @@ func TestMain(m *testing.M) {
// Verify that you can connect to the database
err = db.DB().Ping()
if err != nil {
fmt.Println("Error: DB must ping to run tests")
return
log.Panic("Error: DB must ping to run tests")
}
defer db.Close()
......
......@@ -170,7 +170,7 @@ func CompareResponse(resp *bytes.Buffer, expected interface{}) error {
opts := jsondiff.DefaultConsoleOptions()
diff, text := jsondiff.Compare(resp.Bytes(), expectedBytes, &opts)
if diff.String() != "FullMatch" && diff.String() != "SupersetMatch" {
fmt.Println(text)
log.Println(text)
return fmt.Errorf("Response: Expected \"%v\". Got \"%v\".",
"(FullMatch OR SupersetMatch)", diff.String())
}
......
......@@ -11,6 +11,7 @@ import (
"github.com/jinzhu/gorm"
"github.com/jinzhu/gorm/dialects/postgres"
"github.com/stretchr/testify/assert"
"log"
"os"
"testing"
)
......@@ -41,7 +42,7 @@ func addScenario(token string) (scenarioID uint) {
_, resp, err := helper.TestEndpoint(router, token,
"/api/scenarios", "POST", helper.KeyModels{"scenario": newScenario})
if err != nil {
panic(fmt.Sprint("The following error happend on POSTing a scenario: ", err.Error()))
log.Panic("The following error happend on POSTing a scenario: ", err.Error())
}
// Read newScenario's ID from the response
......
......@@ -286,7 +286,6 @@ func TestAddFile(t *testing.T) {
router.ServeHTTP(w, req)
assert.Equalf(t, 200, w.Code, "Response body: \n%v\n", w.Body)
//fmt.Println(w.Body)
newFileID, err := helper.GetResponseID(w.Body)
assert.NoError(t, err)
......@@ -360,7 +359,6 @@ func TestUpdateFile(t *testing.T) {
router.ServeHTTP(w, req)
assert.Equalf(t, 200, w.Code, "Response body: \n%v\n", w.Body)
//fmt.Println(w.Body)
newFileID, err := helper.GetResponseID(w.Body)
assert.NoError(t, err)
......@@ -435,8 +433,6 @@ func TestUpdateFile(t *testing.T) {
req.Header.Add("Authorization", "Bearer "+token)
router.ServeHTTP(w_updated, req)
assert.Equalf(t, 200, w_updated.Code, "Response body: \n%v\n", w_updated.Body)
//fmt.Println(w_updated.Body)
//assert.Equal(t, c2, w_updated.Header().Get("file"))
newFileIDUpdated, err := helper.GetResponseID(w_updated.Body)
......@@ -484,7 +480,6 @@ func TestDeleteFile(t *testing.T) {
assert.NoError(t, err, "IO copy")
contentType := bodyWriter.FormDataContentType()
bodyWriter.Close()
//req, err := http.NewRequest("POST", "/api/files?objectID=1&objectType=widget", bodyBuf)
// Create the request
w := httptest.NewRecorder()
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment