-
Notifications
You must be signed in to change notification settings - Fork 74
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
controllers/main: Add APIAddress test #602
Conversation
b4c99ff
to
8f1b119
Compare
Will review this after #598 is merged. Feel free to give me a poke if 598 goes in and I forget to revisit this |
8f1b119
to
9ec53cb
Compare
@jholdstock POKE
Prepare yourself. |
return nil, codes.Unauthenticated, "address error", errors.New("invalid api token") | ||
uid, exists := c.Env["APIUserID"].(int64) | ||
if !exists { | ||
return nil, codes.Unauthenticated, "purchaseinfo error", errors.New("invalid api token") |
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.
afaict this should have stayed as "address error"
rather than "purchaseinfo error"
user, err := models.GetUserByID(dbMap, uid) | ||
if err != nil { | ||
log.Warnf("failure to get GetUserByID for user %d: %v", uid, err) | ||
return nil, codes.Internal, "purchaseinfo error", errors.New("internal error") |
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.
"address error"
rather than "purchaseinfo error"
user, _ := models.GetUserByID(dbMap, c.Env["APIUserID"].(int64)) | ||
user, err := models.GetUserByID(dbMap, uid) | ||
if err != nil { | ||
log.Warnf("failure to get GetUserByID for user %d: %v", uid, 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.
This should probably log at Error
level because it could be something wrong with the data in the db, and also we are returning an error to the caller
c.Env["DbMap"] = dbMap | ||
// Put userPubKeyAddr as form value. | ||
r, _ := http.NewRequest("GET", "?UserPubKeyAddr="+test.userPubKeyAddr, nil) | ||
_, errCode, _, _ := mc.APIAddress(c, r) |
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.
I wonder if we should also be checking the other values returned by APIAddress()
.
This actually makes me wonder, do we really need to return both a string response and an error? The error alone is probably sufficient, having both seems redundant.
No description provided.