package booking import ( "testing" "time" "github.com/stretchr/testify/assert" ) func TestService_All(t *testing.T) { tests := []struct { name string mockData []*Line }{ { name: "returns empty list when no bookings", mockData: []*Line{}, }, { name: "returns list of bookings", mockData: []*Line{ { Id: 1, CustomerName: "John Doe", From: time.Date(2024, 1, 1, 0, 0, 0, 0, time.UTC), To: time.Date(2024, 1, 5, 0, 0, 0, 0, time.UTC), Platform: "Airbnb", Total: 500.0, Canceled: false, }, { Id: 2, CustomerName: "Jane Smith", From: time.Date(2024, 2, 1, 0, 0, 0, 0, time.UTC), To: time.Date(2024, 2, 3, 0, 0, 0, 0, time.UTC), Platform: "Booking.com", Total: 300.0, Canceled: true, }, }, }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { // Create mocks mockStore := new(MockStore) mockCalendar := new(MockCalendarClient) mockPDF := new(MockPDFClient) // Set up expectations mockStore.On("All").Return(tt.mockData) // Create service with mocks service, err := NewService(mockStore, mockCalendar, mockPDF) assert.NoError(t, err) // Call the method result := service.All() // Assert expectations assert.Equal(t, tt.mockData, result) mockStore.AssertExpectations(t) }) } }