Skip to content

Commit

Permalink
tmp
Browse files Browse the repository at this point in the history
  • Loading branch information
CommanderStorm committed Sep 22, 2023
1 parent d8921cb commit 4611f6c
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions server/backend/feedback_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ import (
"image"
"image/png"
"io"
"regexp"
"testing"
"time"
)

type FeedbackSuite struct {
Expand Down Expand Up @@ -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++
Expand All @@ -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", "[email protected]", "[email protected]", "Hello World", nil, nil, nil, nil, false).
WillReturnRows(sqlmock.NewRows([]string{"timestamp", "id"}).AddRow(returnedTime, 1))
s.mock.ExpectCommit()

stream := mockedFeedbackStream{
Expand Down

0 comments on commit 4611f6c

Please sign in to comment.