Skip to content
This repository has been archived by the owner on Jul 12, 2023. It is now read-only.

Add tests for users, fix template NPE, fix user HTTP return codes, show validations #1493

Merged
merged 3 commits into from
Dec 30, 2020

Conversation

sethvargo
Copy link
Member

Still needs tests for stats and import, but I'll do that in another PR since this is already large.

Release Note

Add tests for users

@googlebot googlebot added the cla: yes Auto: added by CLA bot when all committers have signed a CLA. label Dec 30, 2020
@sethvargo
Copy link
Member Author

/assign @whaught

@@ -55,39 +55,41 @@
</div>
{{end}}

<nav class="nav nav-tabs navbar-expand-md navbar-light bg-light">
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is just indented (?w=1). It can really only fail in tests, but it's good to guard against it anyway in the template.

@@ -84,7 +83,7 @@ func (c *Controller) HandleUserStats() http.Handler {
c.h.RenderJSON(w, http.StatusOK, stats)
return
default:
controller.InternalError(w, r, c.h, fmt.Errorf("unknown path %q", pth))
controller.BadRequest(w, r, c.h)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Twas a bug

@@ -51,17 +59,42 @@ func (c *Controller) HandleExport() http.Handler {
return
}

w.Header().Add("Content-Disposition", "")
w.Header().Add("Content-Type", "text/CSV")
filename := fmt.Sprintf("%s-users.csv", time.Now().Format(project.RFC3339Squish))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yay nice touch.

I did this to the bulk-upload files in javascript: https://github.com/google/exposure-notifications-verification-server/pull/1469/files

Now I'm wondering if I should flip it with the date first (for string sortability)

Copy link
Member Author

@sethvargo sethvargo Dec 30, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the date being first

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree! I'm saying can you change where I did it wrong for consistency (or I'll slip that in to my next PR)

if err := w.Write([]string{
m.User.Name,
m.User.Email,
m.CreatedAt.Format(project.RFC3339Date),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wondering: why add CreatedAt - presumably when we import these we want a fresh CreatedAt?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we would discard that value on import (we don't consume it). This is for if someone wants to know when someone was added to a realm.

pkg/database/user.go Outdated Show resolved Hide resolved
@sethvargo sethvargo changed the title Add tests for users Add tests for users, fix template NPE, fix user HTTP return codes Dec 30, 2020
@sethvargo sethvargo changed the title Add tests for users, fix template NPE, fix user HTTP return codes Add tests for users, fix template NPE, fix user HTTP return codes, show validatsion Dec 30, 2020
@sethvargo sethvargo changed the title Add tests for users, fix template NPE, fix user HTTP return codes, show validatsion Add tests for users, fix template NPE, fix user HTTP return codes, show validations Dec 30, 2020
@google-oss-robot
Copy link

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: sethvargo, whaught

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@google-oss-robot google-oss-robot merged commit b8c9a44 into main Dec 30, 2020
@google-oss-robot google-oss-robot deleted the sethvargo/user_tests branch December 30, 2020 17:37
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 1, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
cla: yes Auto: added by CLA bot when all committers have signed a CLA.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants