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

ARCO-202: Adding unit test for callerback sender #630

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

kameshraj23
Copy link
Collaborator

Description of Changes

Adding unit test for callerback sender

@boecklim boecklim assigned boecklim and kameshraj23 and unassigned boecklim Nov 5, 2024
}))
defer server.Close()
logger := slog.New(slog.NewTextHandler(new(bytes.Buffer), nil))
sender, err := callbacker.NewSender(server.Client(), logger)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Rename sender to sut

responseStatus: http.StatusOK,
expectedSuccess: true,
expectedRetries: 1,
},
Copy link
Collaborator

Choose a reason for hiding this comment

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

Add another case where responseStatus is an error e.g. http.StatusInternalServerError

func TestCallbackSender_GracefulStop(t *testing.T) {
// Given
logger := slog.New(slog.NewTextHandler(new(bytes.Buffer), nil))
sender, err := callbacker.NewSender(http.DefaultClient, logger)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Rename sender to sut

func TestCallbackSender_Health(t *testing.T) {
// Given
logger := slog.New(slog.NewTextHandler(new(bytes.Buffer), nil))
sender, err := callbacker.NewSender(http.DefaultClient, logger)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Rename sender to sut

// Given
client := &http.Client{}
logger := slog.New(slog.NewJSONHandler(bytes.NewBuffer([]byte{}), nil))
sender, _ := callbacker.NewSender(client, logger)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Rename sender to sut

defer server.Close()

logger := slog.New(slog.NewTextHandler(new(bytes.Buffer), nil))
sender, err := callbacker.NewSender(server.Client(), logger)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Rename sender to sut

dtos: []*callbacker.Callback{{TxID: "1234", TxStatus: "SEEN_ON_NETWORK"}, {TxID: "5678", TxStatus: "MINED"}},
responseStatus: http.StatusOK,
expectedSuccess: true,
},
Copy link
Collaborator

Choose a reason for hiding this comment

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

Add another case where responseStatus is an error e.g. http.StatusInternalServerError

Copy link

sonarcloud bot commented Nov 5, 2024

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