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

fix comment on function SetObserve #391

Merged
merged 1 commit into from
Sep 5, 2022

Conversation

AryanGodara
Copy link
Contributor

Signed-off-by: aryan aryangodara03@gmail.com
With reference to issue #384

Signed-off-by: aryan <aryangodara03@gmail.com>
@AryanGodara
Copy link
Contributor Author

@Danielius1922 , Should I fix the issues, to pass the lint test?
I'm asking before implementing, since it can complicate the PR, by making those other chanes to the code, if it's not necessary.
But if needed, I'll be glad to do it.

@Danielius1922
Copy link
Member

@Danielius1922 , Should I fix the issues, to pass the lint test? I'm asking before implementing, since it can complicate the PR, by making those other chanes to the code, if it's not necessary. But if needed, I'll be glad to do it.

Hey, thanks for the fix, I think I've fixed those and other issues in PR #390, so it's already done. Thus nothing here needs to be done, I'll merge.

@Danielius1922 Danielius1922 merged commit 08c77a2 into plgd-dev:master Sep 5, 2022
@Danielius1922 Danielius1922 linked an issue Sep 5, 2022 that may be closed by this pull request
@AryanGodara AryanGodara deleted the fix-func-doc branch September 5, 2022 15:15
@AryanGodara
Copy link
Contributor Author

@Danielius1922 , I had a request.
I use this library go-coap in my code for coap-adapter. And I want to create unit tests for coap-handler function.
So, does this library offer mocking features, kind of like the httptest.NewServer() for http.
I was thinking of writing a mock-coap server, but that is way out of my league for now, and I kind of only have 2 weeks to finish the task
Or maybe you could suggest a better way to write tests for coap-handlers using go-coap.

@Danielius1922
Copy link
Member

@Danielius1922 , I had a request. I use this library go-coap in my code for coap-adapter. And I want to create unit tests for coap-handler function. So, does this library offer mocking features, kind of like the httptest.NewServer() for http. I was thinking of writing a mock-coap server, but that is way out of my league for now, and I kind of only have 2 weeks to finish the task Or maybe you could suggest a better way to write tests for coap-handlers using go-coap.

No mocking features like those offered by httptest are available currently. I've looked at the source of the httptest library and it's powerful yet small (only 3 implementation files), so creating something like that is possible. We've talked about this with @jkralik and we both agree it would be a nice enhancement, but it's unlikely we will get to it any time soon, the plan is to finish v3 first and then we can look into new features.

So currently the only way I can think of doing what you need is: create a newServer function that makes a coap server running on localhost on some port in a separate go-routine with selected uri handlers. Then call newServer at the start of each client test case. But this is basically the implementation of httptest equivalent. If you go that way you might as well contribute it here, I might have some time to help (usually I have few hours on a Friday to spare).

(Not much of a help I know, sorry. BTW nice avatar, I hope HxH doesn't end up unfinished like Berserk.)

@AryanGodara
Copy link
Contributor Author

@Danielius1922 , I had a request. I use this library go-coap in my code for coap-adapter. And I want to create unit tests for coap-handler function. So, does this library offer mocking features, kind of like the httptest.NewServer() for http. I was thinking of writing a mock-coap server, but that is way out of my league for now, and I kind of only have 2 weeks to finish the task Or maybe you could suggest a better way to write tests for coap-handlers using go-coap.

No mocking features like those offered by httptest are available currently. I've looked at the source of the httptest library and it's powerful yet small (only 3 implementation files), so creating something like that is possible. We've talked about this with @jkralik and we both agree it would be a nice enhancement, but it's unlikely we will get to it any time soon, the plan is to finish v3 first and then we can look into new features.

So currently the only way I can think of doing what you need is: create a newServer function that makes a coap server running on localhost on some port in a separate go-routine with selected uri handlers. Then call newServer at the start of each client test case. But this is basically the implementation of httptest equivalent. If you go that way you might as well contribute it here, I might have some time to help (usually I have few hours on a Friday to spare).

(Not much of a help I know, sorry. BTW nice avatar, I hope HxH doesn't end up unfinished like Berserk.)

Thanks for the reply @Danielius1922 . I'll try to implement this, and will update if I get to this task of creating a mock server.
But since this is a big task, I can't promise any timeline. I'll have to get to it in my free time, when I'm not working on the main tasks.

(I too hope I get to see the entire HxH story 😄)

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.

Comment on SetObserve method is confusing
2 participants