-
Notifications
You must be signed in to change notification settings - Fork 25
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
better logic? #116
base: master
Are you sure you want to change the base?
better logic? #116
Conversation
For testing this I deactivated my |
I only had to run tests to create the fixture so this should fix the flaw you found @GregSutcliffe? |
@@ -20,7 +20,9 @@ if (nzchar(Sys.getenv("MEETUPR_PWD"))) { | |||
meetup_auth(token = temptoken) | |||
|
|||
} else { | |||
Sys.setenv("MEETUPR_TESTING" = TRUE) | |||
if (!identical(Sys.getenv("NOT_CRAN"), "true")) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
on CRAN it's like on CI (apart from the workflow in with-auth.yml) we only want to use the fixtures.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see where you're going, but the double-negative of !NOT-THING isn't ideal. Can we word it as a positive-case, perhaps set "USE_CRAN: true" in the CI config and then it doesn't have to be explicitly disabled by users?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ouch I think this might be where the problem comes from (although I'd like to keep the idea of this code I took from testthat:::on_cran()
)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You shouldn't need to worry about NOT_CRAN
as it is set by devtools (I just re-read ?testthat::skip_on_cran
)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fair enough. Double-negatives are annoying though, though I doubt testthat
would change it given the sheer number of downstream packages that would break ;)
I'm no fan of calling package internals, but would it be better to call
if (testthat:::on_cran) {
To make the double-negative go away and also not duplicate their code into meetupr?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
well as it's not exported I don't think we can. 😬
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fair enough. My own package-writing skills are less polished, I wasn't sure if we could access it during tests (obviously it's not relevant to a production install). Duplication it is - although we could copy the on_cran()
function to internals.R
and then add a link to the source. But I'm nitpicking here, for sure.
@GregSutcliffe I'll wait for your feedback and will amend/merge this within the next few days hopefully. Thanks again for identifying the problem! |
Bad news I'm afraid @maelle, I can't get it to work. I added a test to find_groups, and ran it, and it returned 401. Here's my transcript - I think I did it the way you want?
|
Thank you! Trying to find my mistake. You shouldn't need to run |
my script is that I simply run |
Hmm. this starts to feel like something is borken in my checkout rather than your code then. Let me copy my token to a clean VM and try again. |
oh you know it could well be something on my end!! thanks for your patience |
Ah, thats true, there's a default OAuth provider. I was trying to make sure it was using my token, but I guess that's not needed. One less variable to wory about. Just installing 46746366 devtools dependencies on my VM now :P |
🤞 |
It think it would use your token? As long as it's in the default location that meetupr finds via rappdirs. |
OK, this is a long wall-o-text, sorry for that - I've documented every step so I can be as clean as possible, in case I missed something. This is on a pre-existing vm which has never used meetupr, and I've created a new user so there's no R cache. The only difference is it's R 3.6.3, but as I'm seeing the same issues as my R 4.0.4 laptop, I hope that's not a problem. TL'DR - nope, and I think VCR is the issue. Maybe.
Some notes:
|
Thank you, that's awesome to have all the details. I have just realized I am using vcr's latest version, I've updated the DESCRIPTION: could you please try again? Sorry. |
Still no good, sorry :( Again, here's the steps, I think I got it all.
Very similar YAML produced - It's definitely using the new VCR, I can see the output is way less verbose (all the "HTTP enabled" messages, etc, are gone). |
and the fixture with the error was deleted before re-running the tests? (just trying to eliminate a possibility) |
Yep, you can see |
I can't believe I didn;t think of this earlier, but there's a much cleaner way to show the failure, and be sure it's real, and thats to delete the record for an existing test:
I'm going to poke around inside a few functions and see if i can find what's tripping it up. I added |
Thank you! If I can't look again this week, I'll come back to this next week. |
No worries. The only thing I can see so far that is notable is that without the VCR wrapper, the test will print "Auto-refreshing stale OAuth token." when using my token. With VCR enabled, I don't see this. I'm sure that points to something to do with how tokens are refreshed, but I'm struggling to follow it. |
Aaah that's interesting. The token should have been refreshed before, in the setup/before it. 🤔 I know you know OAuth well, here's the extent of my own understanding: https://blog.r-hub.io/2021/01/25/oauth-2.0/ |
Honestly, I don't. I needed to add it here in a hurry last year, so I did, but that's the first and last time I've needed to implement it myself :). That blog looks handy, added to my reading list, thanks! |
OK, so the problem occurs here: Line 213 in 2ca1098
As far as I can tell, VCR is interfering with this - stepping through the code with Still trying to actually see what VCR has changed in the environment, but it's hard to know where to look. |
So, I feel super bad not looking into this myself now, so don't feel obliged to explore further, but if you're curious, vcr maintainer started writing a vignette about vcr under the hood. ropensci/vcr#233 |
Lack of curiosity is not my main problem :) I'm definitely got the urge to fix it - if neither of us could add a test, I could let it go, but as you can't currently replicate the issue, it's kinda on me to figure out WTH is going on... Hopefully, I can get to the bottom of it. |
@GregSutcliffe