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

Test-post_bug #7

Closed
wants to merge 0 commits into from
Closed

Test-post_bug #7

wants to merge 0 commits into from

Conversation

kpiyush04
Copy link
Contributor

@kpiyush04 kpiyush04 commented Jul 5, 2021

  1. To test the post_bug.R file which also tests the post_help.R file as functions inside the post_help.R file are called in the post_bug.R file.
  2. To check what options can be selected from the menu() when the functions are called the menu() is enabled with the graphics parameter.
    Ex: menu(options, graphics = TRUE, title = title)
  3. When a test case is TRUE but fails due to the stop() statement so it is passed inside the try() statement.
    Ex: try(stop("Do it, later if you are still sure it is a bug then return please.", call. = FALSE))

issue: #4

Copy link
Owner

@llrs llrs left a comment

Choose a reason for hiding this comment

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

Sorry for the late reply.

  1. Yes, it is better to just test the surface, i.e. only functions that are exposed to the user. This way the internals can change without changing tests.
  2. I don't understand this change. Why is it needed? When I ran it with graphics = FALSE and TRUE I got the same results on Rstudio and R terminal.
  3. The functions fails on purpose. Why do you wrap it on try? If an error is expected use expect_error, or are you saying that expect_snapshot can't run when there is an error on the function?

R/post_help.R Outdated
}
invisible(answer)
invisible(answer == TRUE)
Copy link
Owner

Choose a reason for hiding this comment

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

Why change the return element?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The need to change the return statement was that the invisible(answer) returns a string but the expect_equal() statement returns TRUE due to which when we we run devtools::test() it it always throws an error

Copy link
Owner

Choose a reason for hiding this comment

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

Change the expectation not the function. You can use expect_equal can be used to compare the output whatever it is.

@@ -0,0 +1,48 @@
# This is to check the create_bugzilla_key function
Copy link
Owner

Choose a reason for hiding this comment

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

Why is this file being added again? Did you run pr_pull_upstream?

@@ -0,0 +1,7 @@
cli::test_that_cli(configs = "plain", "post_bug() works", {
skip_if_not(interactive())
url <- paste0(missing_host(), "rest/bug")
Copy link
Owner

Choose a reason for hiding this comment

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

Great approach to build up the url, but the function is incomplete and still we need to think what will return to the user. That will depend on what returns the API. If possible it would be nice to return the ID of the bug to be able to look it up on the browser. (but don't test that on this PR)
Finally you added mockery to mock post_bug I don't see any mock function of post_bug being tested.

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