Skip to content

Instantly share code, notes, and snippets.

@okaprinarjaya
Last active January 8, 2022 08:45
Show Gist options
  • Save okaprinarjaya/9311234ad05a78cd0784646b0327e614 to your computer and use it in GitHub Desktop.
Save okaprinarjaya/9311234ad05a78cd0784646b0327e614 to your computer and use it in GitHub Desktop.
threadsMock_Expected := []models.Thread{
{
ID: "123098ABCBCA",
Title: "Title in da house yeah",
Description: "Description description description",
IsActive: 0,
},
{
ID: "T001",
Title: "Thread title one",
Description: "Thread title one Thread title one Thread title one Thread title one Thread title one Thread title one Thread title one",
IsActive: 1,
},
}
rowsMock := func() *sqlmock.Rows {
rows := sqlmock.NewRows([]string{"id", "title", "description", "is_active"})
for _, t := range threadsMock_Expected {
rows.AddRow(t.ID, t.Title, t.Description, t.IsActive)
}
return rows
}()
mock.ExpectQuery("^SELECT (.+) FROM threads").WillReturnRows(rowsMock)
threadList_Actual, _ := thdao.Threads()
assert.Equal(t, threadsMock_Expected, threadList_Actual)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment