-
Notifications
You must be signed in to change notification settings - Fork 2
log messages updated for getAllTestCases & getAllTestSuites functions #76
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,14 +5,15 @@ import ( | |
| "encoding/json" | ||
| "encoding/xml" | ||
| "fmt" | ||
| "github.com/Sirupsen/logrus" | ||
| "github.com/go-chi/chi" | ||
| "github.com/xtracdev/automated-perf-test/testStrategies" | ||
| "io/ioutil" | ||
| "net/http" | ||
| "os" | ||
| "path/filepath" | ||
| "strings" | ||
|
|
||
| "github.com/Sirupsen/logrus" | ||
| "github.com/go-chi/chi" | ||
| "github.com/xtracdev/automated-perf-test/testStrategies" | ||
| ) | ||
|
|
||
| const testCaseSchema string = "testCase_schema.json" | ||
|
|
@@ -150,19 +151,22 @@ func getAllTestCases(rw http.ResponseWriter, req *http.Request) { | |
|
|
||
| file, err := os.Open(fmt.Sprintf("%s%s", testCasePathDir, filename)) | ||
| if err != nil { | ||
| logrus.Error("Cannot Open File: " + filename) | ||
| logrus.Error("File not found: " + filename) | ||
| rw.WriteHeader(http.StatusNotFound) | ||
| continue | ||
| } | ||
|
|
||
| byteValue, err := ioutil.ReadAll(file) | ||
| if err != nil { | ||
| logrus.Error("Cannot Read File: " + filename) | ||
| logrus.Error("An error has occured : " + filename) | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. log the error. this will help with debugging the issue. |
||
| rw.WriteHeader(http.StatusInternalServerError) | ||
| continue | ||
| } | ||
|
|
||
| err = xml.Unmarshal(byteValue, testCase) | ||
| if err != nil { | ||
| logrus.Error("Cannot Unmarshall File: " + filename) | ||
| logrus.Error("Bad request: " + filename) | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. log the error. this will help with debugging the issue. |
||
| rw.WriteHeader(http.StatusBadRequest) | ||
| continue | ||
| } | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -245,17 +245,20 @@ func getAllTestSuites(rw http.ResponseWriter, req *http.Request) { | |
|
|
||
| file, err := os.Open(fmt.Sprintf("%s%s", testSuitePathDir, filename)) | ||
| if err != nil { | ||
| logrus.Error("Cannot open file: ", filename) | ||
| logrus.Error("File not found: ", filename) | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. log the error. this will help with debugging the issue. |
||
| rw.WriteHeader(http.StatusNotFound) | ||
| } | ||
|
|
||
| byteValue, err := ioutil.ReadAll(file) | ||
| if err != nil { | ||
| logrus.Error("Cannot Read File: ", filename) | ||
| logrus.Error("An error has occured: ", filename) | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. log the error. this will help with debugging the issue. |
||
| rw.WriteHeader(http.StatusInternalServerError) | ||
| } | ||
|
|
||
| err = xml.Unmarshal(byteValue, testSuite) | ||
| if err != nil { | ||
| logrus.Error("Cannot Unmarshall: ", filename) | ||
| logrus.Error("Bad request: ", filename) | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. log the error. this will help with debugging the issue. |
||
| rw.WriteHeader(http.StatusBadRequest) | ||
|
|
||
| } | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it not be better to say something like:
logrus.Error("Error opening the file: ", err )I would also add the error as in example.