Skip to content

Commit

Permalink
Added server testcases for engine/subscription.go file (#426)
Browse files Browse the repository at this point in the history
* [MM-836]: Added server testcases for engine/calendar.go file

* [MM-837]: Added server testcase for engine/daily_summary.go file (#12)

* fixed missing function call argumnet

* [MM-838]: Added sever testcase for engine/event_responder.go file (#13)

* Added server testcases for engine/subscription.go file
  • Loading branch information
Kshitij-Katiyar authored Dec 4, 2024
1 parent 0a72bef commit 907c59f
Show file tree
Hide file tree
Showing 3 changed files with 439 additions and 6 deletions.
8 changes: 4 additions & 4 deletions calendar/engine/calendar_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,13 @@ func TestViewCalendar(t *testing.T) {
name: "successful calendar view",
user: GetMockUser(model.NewString(MockRemoteUserID), model.NewString(MockMMModelUserID), MockMMUserID, nil),
setupMock: func() {
mockClient.EXPECT().GetDefaultCalendarView(MockRemoteUserID, from, to).Return([]*remote.Event{{Subject: "Test Event"}}, nil).Times(1)
mockClient.EXPECT().GetDefaultCalendarView(MockRemoteUserID, from, to).Return([]*remote.Event{{Subject: MockEventName}}, nil).Times(1)
},
assertions: func(t *testing.T, events []*remote.Event, err error) {
require.NoError(t, err)
require.NotNil(t, events)
require.Len(t, events, 1)
require.Equal(t, "Test Event", events[0].Subject, "Expected first event's subject to be %s, but got %s", "Test Event", events[0].Subject)
require.Equal(t, MockEventName, events[0].Subject, "Expected first event's subject to be %s, but got %s", MockEventName, events[0].Subject)
},
},
}
Expand Down Expand Up @@ -231,7 +231,7 @@ func TestCreateEvent(t *testing.T) {
mockStore.EXPECT().LoadUser(MockMMUserID).Return(nil, errors.New("not found")).Times(1)
mockPluginAPI.EXPECT().GetMattermostUser(MockMMUserID)
mockPoster.EXPECT().DM(MockMMUserID, gomock.AssignableToTypeOf(""), "testDisplayName", "testDisplayName", "testCommandTrigger").Return("", fmt.Errorf("error creating DM")).Times(1).Return("", nil)
mockClient.EXPECT().CreateEvent(MockRemoteUserID, &remote.Event{Subject: "Test Event"}).Return(nil, fmt.Errorf("error creating event")).Times(1)
mockClient.EXPECT().CreateEvent(MockRemoteUserID, &remote.Event{Subject: MockEventName}).Return(nil, fmt.Errorf("error creating event")).Times(1)
},
assertions: func(t *testing.T, createdEvent *remote.Event, err error) {
require.EqualError(t, err, "error creating event")
Expand All @@ -252,7 +252,7 @@ func TestCreateEvent(t *testing.T) {
mockPluginAPI.EXPECT().GetMattermostUser(MockMMUserID)
mockPoster.EXPECT().DM(MockMMUserID, gomock.AssignableToTypeOf(""), "testDisplayName", "testDisplayName", "testCommandTrigger").Return("", fmt.Errorf("error creating DM")).Times(1).Return("", nil)
mockClient.EXPECT().CreateEvent(MockRemoteUserID, &remote.Event{
Subject: "Test Event",
Subject: MockEventName,
Location: &remote.Location{DisplayName: "Test Location"},
Start: &remote.DateTime{DateTime: "2024-10-01T09:00:00", TimeZone: "UTC"},
End: &remote.DateTime{DateTime: "2024-10-01T10:00:00", TimeZone: "UTC"},
Expand Down
Loading

0 comments on commit 907c59f

Please sign in to comment.