1package models23import "testing"45func TestFilterUpcomingPresentations(t *testing.T) {6 data := &Data{7 Presentations: []Presentation{8 {Slug: "movie-1", IsHidden: false},9 {Slug: "movie-2", IsHidden: false},10 {Slug: "movie-3", IsHidden: true},11 },12 Sessions: []Session{13 {PresentationSlug: "movie-1", Status: "ONSALE"},14 {PresentationSlug: "movie-2", Status: "PAST"},15 {PresentationSlug: "movie-3", Status: "ONSALE"},16 },17 }1819 presentations := data.FilterUpcomingPresentations()2021 if len(presentations) != 1 {22 t.Errorf("Expected 1 upcoming presentation, got %d", len(presentations))23 }2425 if presentations[0].Slug != "movie-1" {26 t.Errorf("Expected 'movie-1', got '%s'", presentations[0].Slug)27 }28}2930func TestGetSessionsForPresentation(t *testing.T) {31 data := &Data{32 Sessions: []Session{33 {PresentationSlug: "movie-1", Status: "ONSALE", SessionId: "1"},34 {PresentationSlug: "movie-1", Status: "ONSALE", SessionId: "2"},35 {PresentationSlug: "movie-1", Status: "PAST", SessionId: "3"},36 {PresentationSlug: "movie-2", Status: "ONSALE", SessionId: "4"},37 },38 }3940 sessions := data.GetSessionsForPresentation("movie-1")4142 if len(sessions) != 2 {43 t.Errorf("Expected 2 sessions for movie-1, got %d", len(sessions))44 }45}4647func TestGetCinema(t *testing.T) {48 data := &Data{49 Market: []Market{50 {51 Cinemas: []Cinema{52 {ID: "0403", Name: "Westminster"},53 },54 },55 },56 }5758 cinema := data.GetCinema("0403")5960 if cinema == nil {61 t.Fatal("Expected cinema, got nil")62 }6364 if cinema.Name != "Westminster" {65 t.Errorf("Expected 'Westminster', got '%s'", cinema.Name)66 }6768 if data.GetCinema("invalid") != nil {69 t.Error("Expected nil for invalid cinema ID")70 }71}7273func TestGetFormat(t *testing.T) {74 data := &Data{75 Formats: []Format{76 {Slug: "2d-digital", Title: "2D Digital"},77 {Slug: "the-big-show", Title: "The Big Show"},78 },79 }8081 format := data.GetFormat("2d-digital")8283 if format == nil {84 t.Fatal("Expected format, got nil")85 }8687 if format.Title != "2D Digital" {88 t.Errorf("Expected '2D Digital', got '%s'", format.Title)89 }90}9192func TestGetAgePolicy(t *testing.T) {93 data := &Data{94 AgePolicies: []AgePolicy{95 {Slug: "rated-pg-13", Name: "Rated PG-13"},96 {Slug: "rated-r", Name: "Rated R"},97 },98 }99100 policy := data.GetAgePolicy("rated-pg-13")101102 if policy == nil {103 t.Fatal("Expected age policy, got nil")104 }105106 if policy.Name != "Rated PG-13" {107 t.Errorf("Expected 'Rated PG-13', got '%s'", policy.Name)108 }109}