-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(testing): Adding unit test for todo/handler layer. #8
base: main
Are you sure you want to change the base?
Conversation
DeleteTodo(ctx context.Context, id primitive.ObjectID) error | ||
} | ||
|
||
type todoServiceImpl struct { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
todoServiceImpl ismi yerine interface ismiyle aynı olması kod okunabirliği açısından daha iyi olur. ayrıca repository tarafında yaptığına yapıya uygun olur o yüzden bu simi
todoService olarak değiştirmen daha okunaklı olur.
@@ -0,0 +1,31 @@ | |||
package todo |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mock kısmını başka bir dosyaya yazmaktanda test yapacağın yere eklemeye ne dersin?.
örnek; burda burda servisi mockluyorsun dimi? neyi test edeceksin handler dosyasını. bu mocklama işi handler a taşınılabilir? böylece gereksiz dosyalardan da kurtulmuş oluruz
} | ||
|
||
func (h *TodoHandler) GetAllTodos(c *fiber.Ctx) error { | ||
func (h *TodoHandler) GetAllTodosHandler(c *fiber.Ctx) error { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
isimlendirmeyi değiştirmenin bir sebebi var mı?
mockService.AssertExpectations(t) | ||
} | ||
|
||
func TestCreateTodoHandler(t *testing.T) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#9 bu testin hata vermesinin sebebi sana cevap olarak formatlı geliyor. PR ı inceleyebilirsin
"go.mongodb.org/mongo-driver/bson/primitive" | ||
) | ||
|
||
func TestGetAllTodosHandler(t *testing.T) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
burdaki testin geçmiyor
No description provided.