From 4611f6c20db53102f94668e596ff663942b67629 Mon Sep 17 00:00:00 2001 From: Frank Elsinga Date: Sat, 23 Sep 2023 01:26:34 +0200 Subject: [PATCH] tmp --- server/backend/feedback_test.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/server/backend/feedback_test.go b/server/backend/feedback_test.go index e76f639b..88a46acd 100644 --- a/server/backend/feedback_test.go +++ b/server/backend/feedback_test.go @@ -14,7 +14,9 @@ import ( "image" "image/png" "io" + "regexp" "testing" + "time" ) type FeedbackSuite struct { @@ -60,7 +62,7 @@ func (f mockedFeedbackStream) SendAndClose(reply *pb.SendFeedbackReply) error { var index = uint(0) func (f mockedFeedbackStream) Recv() (*pb.SendFeedbackRequest, error) { - if len(f.recived) >= int(index) { + if int(index) >= len(f.recived) { return nil, io.EOF } index++ @@ -86,7 +88,10 @@ func createDummyImage(t *testing.T, width, height int) []byte { func (s *FeedbackSuite) Test_SendFeedback() { server := CampusServer{db: s.DB} s.mock.ExpectBegin() - s.mock.ExpectQuery("MOCKED_QUERY") + returnedTime := time.Now() + s.mock.ExpectQuery(regexp.QuoteMeta("INSERT INTO `feedback` (`image_count`,`email_id`,`receiver`,`reply_to`,`feedback`,`latitude`,`longitude`,`os_version`,`app_version`,`processed`) VALUES (?,?,?,?,?,?,?,?,?,?) RETURNING `timestamp`,`id`")). + WithArgs(0, "018abf31-8bb5-79ee-b08c-aed101c6e9f7", "app@tum.de", "testing@example.com", "Hello World", nil, nil, nil, nil, false). + WillReturnRows(sqlmock.NewRows([]string{"timestamp", "id"}).AddRow(returnedTime, 1)) s.mock.ExpectCommit() stream := mockedFeedbackStream{