-
Notifications
You must be signed in to change notification settings - Fork 0
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
Service endpoint error handling and automated tests #151
base: main
Are you sure you want to change the base?
Conversation
@@ -77,6 +80,8 @@ func writeJson(w http.ResponseWriter, object interface{}) { | |||
output, err := json.Marshal(object) | |||
if err != nil { | |||
fmt.Println("error:", err) |
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.
We probably should write this as log.Printf("%v", err)
} | ||
dbService := m.DbClient.GetServiceById(serviceId) | ||
dbService, err := m.DbClient.GetServiceById(serviceId) |
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.
We should check this err
right here
var service Service | ||
err := row.Scan(&service.Id, &service.CreatedAt, &service.UpdatedAt, &service.Name, &service.LongDescription, &service.Eligibility, &service.RequiredDocuments, &service.Fee, &service.ApplicationProcess, &service.ResourceId, &service.VerifiedAt, &service.Email, &service.Status, &service.Certified, &service.ProgramId, &service.InterpretationServices, &service.Url, &service.WaitTime, &service.ContactId, &service.FundingId, &service.AlternateName, &service.CertifiedAt, &service.Featured, &service.SourceAttribution, &service.InternalNote, &service.ShortDescription) | ||
if err != nil { |
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.
good
@@ -34,7 +34,7 @@ func (m *Manager) Submit(w http.ResponseWriter, r *http.Request) { | |||
var service *db.Service | |||
switch changeRequest.Type { | |||
case "ServiceChangeRequest": | |||
service = m.DbClient.GetServiceById(changeRequest.ObjectID) | |||
service, err = m.DbClient.GetServiceById(changeRequest.ObjectID) |
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.
Should check this err
right here
@@ -44,6 +44,13 @@ func TestGetServiceByID(t *testing.T) { | |||
assert.Equal(t, serviceResponse.Service.Id, serviceId, "Service Id is a match") | |||
} | |||
|
|||
func TestGetServiceByIDWithInvalidID(t *testing.T) { |
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.
cool, any issues using the test?
No description provided.