Last active
January 8, 2022 08:45
-
-
Save okaprinarjaya/9311234ad05a78cd0784646b0327e614 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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