Removed dead attendees DB code.
This commit is contained in:
parent
7dbcd05262
commit
ad8c3a64b6
2 changed files with 4 additions and 415 deletions
94
db_test.go
94
db_test.go
|
|
@ -7,7 +7,7 @@ import (
|
|||
func TestMigrate(t *testing.T) {
|
||||
app := testApp(t)
|
||||
// Verify tables exist by querying each one
|
||||
tables := []string{"event", "participants", "participant_roles", "attendees", "departments", "volunteers", "shifts", "volunteer_shifts"}
|
||||
tables := []string{"event", "participants", "participant_roles", "departments", "volunteers", "shifts", "volunteer_shifts"}
|
||||
for _, table := range tables {
|
||||
var count int
|
||||
err := app.db.QueryRow("SELECT COUNT(*) FROM " + table).Scan(&count)
|
||||
|
|
@ -17,98 +17,6 @@ func TestMigrate(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestAttendeesCRUD(t *testing.T) {
|
||||
app := testApp(t)
|
||||
|
||||
a, err := app.createAttendee(Attendee{Name: "Titania", Email: "titania@test.com", TicketType: "GA"})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if a.ID == 0 || a.Name != "Titania" {
|
||||
t.Errorf("create: got %+v", a)
|
||||
}
|
||||
|
||||
got, err := app.getAttendee(a.ID)
|
||||
if err != nil || got == nil {
|
||||
t.Fatal("get: not found")
|
||||
}
|
||||
if got.Email != "titania@test.com" {
|
||||
t.Errorf("get: email = %q", got.Email)
|
||||
}
|
||||
|
||||
got.Name = "Titania Fairweather"
|
||||
if err := app.updateAttendee(*got); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
got2, _ := app.getAttendee(a.ID)
|
||||
if got2.Name != "Titania Fairweather" {
|
||||
t.Errorf("update: name = %q", got2.Name)
|
||||
}
|
||||
|
||||
if err := app.deleteAttendee(a.ID); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
// getAttendee returns soft-deleted records; listAttendees filters them
|
||||
attendees, _ := app.listAttendees("", "", "")
|
||||
for _, at := range attendees {
|
||||
if at.ID == a.ID {
|
||||
t.Error("delete: still visible in list")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestIncrementPartySize(t *testing.T) {
|
||||
app := testApp(t)
|
||||
|
||||
app.createAttendee(Attendee{Name: "Oberon", TicketID: "ORD-100"})
|
||||
|
||||
merged, err := app.incrementPartySize("Oberon", "ORD-100")
|
||||
if err != nil || !merged {
|
||||
t.Fatalf("increment: merged=%v, err=%v", merged, err)
|
||||
}
|
||||
|
||||
a, _ := app.getAttendee(1)
|
||||
if a.PartySize != 2 {
|
||||
t.Errorf("party_size = %d, want 2", a.PartySize)
|
||||
}
|
||||
|
||||
// Different ticket_id should not merge
|
||||
merged2, _ := app.incrementPartySize("Oberon", "ORD-200")
|
||||
if merged2 {
|
||||
t.Error("should not merge different ticket_id")
|
||||
}
|
||||
}
|
||||
|
||||
func TestCheckInAttendee(t *testing.T) {
|
||||
app := testApp(t)
|
||||
admin := testAdminUser(t, app)
|
||||
|
||||
app.createAttendee(Attendee{Name: "Puck"})
|
||||
// Set party_size directly since createAttendee defaults to 1
|
||||
app.db.Exec(`UPDATE attendees SET party_size = 3 WHERE id = 1`)
|
||||
|
||||
// Check in 1
|
||||
a, err := app.checkInAttendee(1, admin.ID, 1)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if a.CheckedInCount != 1 || !a.CheckedIn {
|
||||
t.Errorf("after 1: count=%d, checked_in=%v", a.CheckedInCount, a.CheckedIn)
|
||||
}
|
||||
|
||||
// Check in 2 more (should cap at party_size=3)
|
||||
a, _ = app.checkInAttendee(1, admin.ID, 5)
|
||||
if a.CheckedInCount != 3 {
|
||||
t.Errorf("after cap: count=%d, want 3", a.CheckedInCount)
|
||||
}
|
||||
|
||||
// Check in again — already full, should stay at 3
|
||||
a, _ = app.checkInAttendee(1, admin.ID, 1)
|
||||
if a.CheckedInCount != 3 {
|
||||
t.Errorf("after full: count=%d, want 3", a.CheckedInCount)
|
||||
}
|
||||
}
|
||||
|
||||
func TestGenerateToken(t *testing.T) {
|
||||
token, err := generateToken()
|
||||
if err != nil {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue