Skip to content
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

[Kayrock Preparations] Structs and unit tests #483

Merged
merged 11 commits into from
Sep 7, 2023

Conversation

Argonus
Copy link
Contributor

@Argonus Argonus commented May 9, 2023

Overview

  • Nest structs under struct dir to make code easier to read. This will bound all same kind of modules under same path in application code.
  • Add more unit tests for structs, and basic functions. More will come with next PR's. I'm aiming to separate integration tests & unit tests in 100% and make it easy to do plain TDD approach.
  • Add Hammox & first behaviours to be able to type-safe mocks in unit tests.
  • A bit of refactor for test helper modules

What Next?

  • Describe groups endpoint using Kayrock only
  • Migrate next endpoints to Kayrock (2 probably)
  • Add more unit tests

Goal

  • Migrate all endpoints to Kayrock
  • Refactor Unit Tests, to make them capable to helping in TDD

@Argonus Argonus marked this pull request as draft May 9, 2023 15:16
@Argonus Argonus marked this pull request as ready for review May 10, 2023 06:20
@Argonus Argonus requested review from bjhaid and jbruggem May 16, 2023 12:42
lib/kafka_ex/new/structs/node_selector.ex Outdated Show resolved Hide resolved
mix.exs Outdated Show resolved Hide resolved
defmodule KafkaEx.NetworkClientTest do
use ExUnit.Case, async: true

use Hammox.Protect,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've not used Hammox, but reading through and doing some testing myself, it seems like this call just creates wrappers that will additionally fail if dialyzer types don't match? In testing locally, the function calls here are definitely still calling through to the originals, so there are no real mocks created.

Copy link
Contributor Author

@Argonus Argonus Jun 3, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm using Hammox quite a lot.
You have two modes there, one with use Hamox.Protect it will wrap function & check in in run time same way as dialyzer in compile time. It's quite useful as it allows you to validate behaviors when dialyzer sometimes is too optimistic.

I prefer to test it both ways, using DIalyzer & Hammox, but if you think it's overkill we can drop one. As end goal, I'd like to make it easy to mock entire kafka_ex in projects with type safe behaviours.

@Argonus Argonus requested a review from joshuawscott June 3, 2023 06:37
@Argonus
Copy link
Contributor Author

Argonus commented Jun 16, 2023

@joshuawscott is it ok?

@Argonus Argonus requested review from joshuawscott and removed request for dantswain, bjhaid and jbruggem August 3, 2023 11:17
@Argonus Argonus force-pushed the KP-p1-structs-and-unit-tests branch from 7f4c850 to e4a306f Compare August 3, 2023 11:37
@Argonus Argonus merged commit 970ba78 into kafkaex:master Sep 7, 2023
10 checks passed
@Argonus Argonus deleted the KP-p1-structs-and-unit-tests branch September 7, 2023 08:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants