Skip to content

Commit

Permalink
Merge pull request #294 from CircleCI-Public/bugfix-setup-diagnostic-…
Browse files Browse the repository at this point in the history
…check

[CIRCLE-17397] Bugfix setup diagnostic check
  • Loading branch information
iynere authored Apr 11, 2019
2 parents 82d3083 + fb6b1ef commit 1fae6c8
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
9 changes: 6 additions & 3 deletions cmd/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -206,11 +206,14 @@ func setupDiagnosticCheck(opts setupOptions) {
fmt.Println("Ok.")
}

fmt.Printf("Trying to query your username given the provided token... ")
fmt.Printf("Trying to query our API for your profile name... ")
responseWho, err := api.WhoamiQuery(opts.cl)

if err != nil || responseWho.Me.Name == "" {
fmt.Println("\nUnable to query the GraphQL API for your username, please check your settings.")
if err != nil {
fmt.Println("\nUnable to query our API for your profile name, please check your settings.")
// If user does not have a name set in their VCS, let's just say hi :)
} else if responseWho.Me.Name == "" {
fmt.Printf("Hello!")
} else {
fmt.Printf("Hello, %s.\n", responseWho.Me.Name)
}
Expand Down
10 changes: 5 additions & 5 deletions cmd/setup_unit_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ Setup complete.
Your configuration has been saved to %s.
Trying an introspection query on API to verify your setup... Ok.
Trying to query your username given the provided token... Hello, %s.
Trying to query our API for your profile name... Hello, %s.
`, tempSettings.Config.Path, `zomg`)))

tempSettings.AssertConfigRereadMatches(fmt.Sprintf(`host: %s
Expand Down Expand Up @@ -162,7 +162,7 @@ Setup complete.
Your configuration has been saved to %s.
Trying an introspection query on API to verify your setup... Ok.
Trying to query your username given the provided token... Hello, %s.
Trying to query our API for your profile name... Hello, %s.
`, tempSettings.Config.Path, `zomg`)))

tempSettings.AssertConfigRereadMatches(fmt.Sprintf(`host: %s
Expand Down Expand Up @@ -242,7 +242,7 @@ Your configuration has been saved to %s.
Trying an introspection query on API to verify your setup...
Unable to make a query against the GraphQL API, please check your settings.
Trying to query your username given the provided token... Hello, %s.
Trying to query our API for your profile name... Hello, %s.
`, tempSettings.Config.Path, `zomg`)))
})
})
Expand Down Expand Up @@ -316,8 +316,8 @@ Setup complete.
Your configuration has been saved to %s.
Trying an introspection query on API to verify your setup... Ok.
Trying to query your username given the provided token...
Unable to query the GraphQL API for your username, please check your settings.
Trying to query our API for your profile name...
Unable to query our API for your profile name, please check your settings.
`, tempSettings.Config.Path)))
})
})
Expand Down

0 comments on commit 1fae6c8

Please sign in to comment.