Skip to content

Instantly share code, notes, and snippets.

View joshuabezaleel's full-sized avatar

Joshua Bezaleel Abednego joshuabezaleel

View GitHub Profile
var bookRepository = &MockRepository{}
var bookService = service{bookRepository: bookRepository}
func TestCreate(t *testing.T) {
book := NewBook("testID", "testTitle", "testAuthor")
bookRepository.On("Create", book).Return(book, nil)
createdBook, err := bookService.Create(book)
require.Nil(t, err)
require.Equal(t, createdBook.ID, book.ID)
}
var bookService = &book.MockService{}
var bookTestingHandler = bookHandler{bookService}
func TestCreate(t *testing.T) {
initialBook := book.NewBook("testID", "testTitle", "testAuthor")
bookService.On("Create", initialBook).Return(initialBook, nil)
url := fmt.Sprintf("/books")
jsonReq, _ := json.Marshal(initialBook)
req := httptest.NewRequest("POST", url, bytes.NewBuffer(jsonReq))
rr := httptest.NewRecorder()
bookTestingHandler.getBook(rr, req)
mockDB, mock, err := sqlmock.New()
require.Nil(t, err)
defer mockDB.Close()
db := sqlx.NewDb(mockDB, "sqlmock")
bookRepository := NewBookRepository(db)
func TestGet(t *testing.T) {
mockDB, mock, err := sqlmock.New()
require.Nil(t, err)
defer mockDB.Close()
db := sqlx.NewDb(mockDB, "sqlmock")
bookRepository := NewBookRepository(db)
rows := sqlmock.NewRows([]string{"id, title, author"}).
AddRow("testID", "testTitle", "testAuthor")

Creating a New Meetup Group in Your City

Cloudnative ID is the parent organization/association for Kubernetes/Cloud Native (CNCF) Meetup Groups across Indonesia. We are supported by CNCF Meetup Groups. The official CNCF meetup guideline is recommended to be read.

Below you can find an ongoing non-exhaustive guide/checklist for starting a new Kubernetes/Cloud Native Meetup Group in your own city.

Initial Preparation

  • Make sure that there is no existing Kubernetes/Cloud Native Meetup Group in your city.
func calculate(input ...int, method string) int {
var result int
if method == "fibonacci" {
result = fibRec(input[0])
}
return result
}
func fibRec(n int) int {
if n <= 1 {
@joshuabezaleel
joshuabezaleel / ennui.md
Created October 14, 2020 12:27 — forked from vilmibm/ennui.md
a plath poem

Ennui

Tea leaves thwart those who court catastrophe,
designing futures where nothing will occur:
cross the gypsy’s palm and yawning she
will still predict no perils left to conquer.
Jeopardy is jejune now: naïve knight
finds ogres out-of-date and dragons unheard
of, while blasé princesses indict

tilts at terror as downright absurd.

@joshuabezaleel
joshuabezaleel / test
Last active October 14, 2020 12:52
test fork
test1
test2
test3
test4
test192837219837192837