Cleaned up old Attendees model. Updated tests.
This commit is contained in:
parent
64ce97c74d
commit
d804a48b49
9 changed files with 75 additions and 285 deletions
|
|
@ -55,17 +55,19 @@ func TestUpdateSettings(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestResetAttendees(t *testing.T) {
|
||||
func TestResetTickets(t *testing.T) {
|
||||
app := testApp(t)
|
||||
admin := testAdminUser(t, app)
|
||||
token := testToken(t, app, admin)
|
||||
mux := testMux(app)
|
||||
|
||||
app.createAttendee(Attendee{Name: "Titania", Email: "titania@example.com"})
|
||||
app.createAttendee(Attendee{Name: "Oberon", Email: "oberon@example.com"})
|
||||
p1, _ := app.createParticipant(Participant{PreferredName: "Titania", Email: "titania@example.com"})
|
||||
p2, _ := app.createParticipant(Participant{PreferredName: "Oberon", Email: "oberon@example.com"})
|
||||
app.createTicket(Ticket{ParticipantID: &p1.ID, Name: "Titania", Source: "manual"})
|
||||
app.createTicket(Ticket{ParticipantID: &p2.ID, Name: "Oberon", Source: "manual"})
|
||||
|
||||
w := httptest.NewRecorder()
|
||||
mux.ServeHTTP(w, testAuthRequest("POST", "/api/settings/reset-attendees", nil, token))
|
||||
mux.ServeHTTP(w, testAuthRequest("POST", "/api/settings/reset-tickets", nil, token))
|
||||
|
||||
if w.Code != 200 {
|
||||
t.Fatalf("status = %d: %s", w.Code, w.Body.String())
|
||||
|
|
@ -75,20 +77,20 @@ func TestResetAttendees(t *testing.T) {
|
|||
t.Fatalf("deleted = %v, want 2", result["deleted"])
|
||||
}
|
||||
|
||||
attendees, _ := app.listAttendees("", "", "")
|
||||
if len(attendees) != 0 {
|
||||
t.Fatalf("attendees remaining = %d, want 0", len(attendees))
|
||||
tickets, _ := app.listTickets(nil, "")
|
||||
if len(tickets) != 0 {
|
||||
t.Fatalf("tickets remaining = %d, want 0", len(tickets))
|
||||
}
|
||||
}
|
||||
|
||||
func TestResetAttendeesRequiresAdmin(t *testing.T) {
|
||||
func TestResetTicketsRequiresAdmin(t *testing.T) {
|
||||
app := testApp(t)
|
||||
gate := testUserWithRole(t, app, "gate1", "gatekeeper", []int{})
|
||||
token := testToken(t, app, gate)
|
||||
mux := testMux(app)
|
||||
|
||||
w := httptest.NewRecorder()
|
||||
mux.ServeHTTP(w, testAuthRequest("POST", "/api/settings/reset-attendees", nil, token))
|
||||
mux.ServeHTTP(w, testAuthRequest("POST", "/api/settings/reset-tickets", nil, token))
|
||||
|
||||
if w.Code != 403 {
|
||||
t.Fatalf("status = %d, want 403", w.Code)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue