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

fixing nil check for validString check #96

Merged
merged 3 commits into from
Dec 13, 2019
Merged

Conversation

veverkap
Copy link
Contributor

So, o.PrivateKey references a memory address it seems, not a string value so it's never nil.

@veverkap veverkap added the bug Something isn't working label Dec 12, 2019
Copy link
Member

@alisdair alisdair left a comment

Choose a reason for hiding this comment

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

Can we add test coverage for this?

@veverkap
Copy link
Contributor Author

veverkap commented Dec 12, 2019

Can we add test coverage for this?

So, um, there WAS test coverage but it didn't work.

go-tfe/oauth_client_test.go

Lines 285 to 309 in 4b1fc6f

t.Run("with private key and not ado_server options", func(t *testing.T) {
options := OAuthClientCreateOptions{
APIURL: String("https://api.github.com"),
HTTPURL: String("https://github.com"),
OAuthToken: String("NOTHING"),
ServiceProvider: ServiceProvider(ServiceProviderGithub),
PrivateKey: String("NOTHING"),
}
err := options.valid()
assert.EqualError(t, err, "Private Key can only be present with Azure DevOps Server service provider")
})
t.Run("with valid options including private key", func(t *testing.T) {
options := OAuthClientCreateOptions{
APIURL: String("https://ado.example.com"),
HTTPURL: String("https://ado.example.com"),
OAuthToken: String("NOTHING"),
ServiceProvider: ServiceProvider(ServiceProviderAzureDevOpsServer),
PrivateKey: String("NOTHING"),
}
err := options.valid()
assert.Nil(t, err)
})

It's possible I'm doing it wrong.

@veverkap
Copy link
Contributor Author

Can we add test coverage for this?

I added in a better test per your suggestion @alisdair

@veverkap veverkap merged commit 8b656f1 into master Dec 13, 2019
@veverkap veverkap deleted the veverkap/ado_bugfix branch December 13, 2019 17:13
@veverkap veverkap restored the veverkap/ado_bugfix branch December 13, 2019 17:13
@veverkap veverkap deleted the veverkap/ado_bugfix branch December 13, 2019 17:14
@lafentres lafentres restored the veverkap/ado_bugfix branch January 29, 2020 19:03
@lafentres lafentres deleted the veverkap/ado_bugfix branch January 29, 2020 19:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants