Go SDK: add unit tests for ClusterNodeRole

Open Beginner friendly
#5,035 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 2 days

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
88/100
Issue type
Feature
Clarity
Clearly specified
Activity status
Active
Tech stack
go
Domain
api

Research direction

The methods under test are ClusterNodeRoleTryFrom, MarshalBinary, UnmarshalBinary and String in foreign/go/contracts/role.go. Read compression_algorithm_test.go in the same folder to copy its table-test style into a new role_test.go in package iggcon. Cover bytes 0, 1 and 2, a binary round trip, the nil and invalid-byte error cases, and the three string outputs. Done when go test ./contracts/... and go vet ./... pass in foreign/go.

Written by the indexing model from the issue text.

Description

go good first issue test
Description

ClusterNodeRoleTryFrom, MarshalBinary, UnmarshalBinary and String in foreign/go/contracts/role.go have no test of their own. ClusterNodeRoleTryFrom accepts only 0 (leader) and 1 (follower) and returns ierror.ErrInvalidCommand otherwise. UnmarshalBinary rejects an empty slice. String returns leader, follower or unknown. Other tests use the role constants as fixtures, but none checks these methods.

Affected area / component

Go SDK

Proposed solution

Add foreign/go/contracts/role_test.go in package iggcon, modelled on compression_algorithm_test.go in the same folder.

  • A table test over bytes 0, 1 and 2 for ClusterNodeRoleTryFrom, checking the value or the error.
  • A round trip through MarshalBinary and UnmarshalBinary.
  • Check that UnmarshalBinary(nil) and an invalid byte return the error.
  • Check the three String outputs.

How to test: go test ./contracts/... and go vet ./... pass in foreign/go.

Good first issue
  • I think this could be a good first issue for a new contributor
Dominant language
Rust
Stars
5.3k
Forks
548
Avg merge
2d 20h
Merged PRs (30d)
194

Getting set up

Open in Codespaces

Starts the project's dev container in your browser, under your own GitHub account.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from apache/iggy

All issues in apache/iggy

Similar issues

More Rust issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.