From 2708e6b6afa8af6ddf98ca1d18f76e914669de48 Mon Sep 17 00:00:00 2001 From: iynere Date: Wed, 10 Apr 2019 14:56:27 -0400 Subject: [PATCH 1/9] fix diagnostic check error message --- cmd/setup.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/cmd/setup.go b/cmd/setup.go index 63bb31da3..5b61d38f6 100644 --- a/cmd/setup.go +++ b/cmd/setup.go @@ -209,8 +209,11 @@ func setupDiagnosticCheck(opts setupOptions) { fmt.Printf("Trying to query your username given the provided token... ") 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 make a query against the GraphQL API, please check your settings.") + // If user does not have a name set in their VCS, return their login (VCS handle) instead + } else if responseWho.Me.Name == "" { + fmt.Printf("Hello, %s.\n", responseWho.Me.Login) } else { fmt.Printf("Hello, %s.\n", responseWho.Me.Name) } From 099057a5f0b861804939bb42bf90f902694abfb1 Mon Sep 17 00:00:00 2001 From: iynere Date: Wed, 10 Apr 2019 15:02:43 -0400 Subject: [PATCH 2/9] include login in whoamiresponse func --- api/api.go | 1 + 1 file changed, 1 insertion(+) diff --git a/api/api.go b/api/api.go index 5e7ca91dc..b2432c6ee 100644 --- a/api/api.go +++ b/api/api.go @@ -140,6 +140,7 @@ type GetOrganizationResponse struct { // WhoamiResponse type matches the data shape of the GQL response for the current user type WhoamiResponse struct { Me struct { + Login string Name string } } From 8e386aef41ab8a773b449a52db65ef7fac189481 Mon Sep 17 00:00:00 2001 From: iynere Date: Wed, 10 Apr 2019 15:08:44 -0400 Subject: [PATCH 3/9] gofmt --- api/api.go | 2 +- cmd/setup.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/api/api.go b/api/api.go index b2432c6ee..7de680004 100644 --- a/api/api.go +++ b/api/api.go @@ -141,7 +141,7 @@ type GetOrganizationResponse struct { type WhoamiResponse struct { Me struct { Login string - Name string + Name string } } diff --git a/cmd/setup.go b/cmd/setup.go index 5b61d38f6..316352ce8 100644 --- a/cmd/setup.go +++ b/cmd/setup.go @@ -211,7 +211,7 @@ func setupDiagnosticCheck(opts setupOptions) { if err != nil { fmt.Println("\nUnable to make a query against the GraphQL API, please check your settings.") - // If user does not have a name set in their VCS, return their login (VCS handle) instead + // If user does not have a name set in their VCS, return their login (VCS handle) instead } else if responseWho.Me.Name == "" { fmt.Printf("Hello, %s.\n", responseWho.Me.Login) } else { From 224cb797a02014f7008c56264f60533c6eeabdce Mon Sep 17 00:00:00 2001 From: iynere Date: Wed, 10 Apr 2019 15:14:59 -0400 Subject: [PATCH 4/9] update unit test --- cmd/setup_unit_test.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cmd/setup_unit_test.go b/cmd/setup_unit_test.go index 011acae4a..1a97f3fe2 100644 --- a/cmd/setup_unit_test.go +++ b/cmd/setup_unit_test.go @@ -240,7 +240,7 @@ Do you want to reset the endpoint? (default: graphql-unstable) Setup complete. Your configuration has been saved to %s. -Trying an introspection query on API to verify your setup... +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. `, tempSettings.Config.Path, `zomg`))) @@ -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 your username given the provided token... +Unable to make a query against the GraphQL API, please check your settings. `, tempSettings.Config.Path))) }) }) From 90473419f45988fe254f95437254094b2ca4fd93 Mon Sep 17 00:00:00 2001 From: iynere Date: Wed, 10 Apr 2019 15:20:46 -0400 Subject: [PATCH 5/9] ugh --- cmd/setup_unit_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/setup_unit_test.go b/cmd/setup_unit_test.go index 1a97f3fe2..f031cefd8 100644 --- a/cmd/setup_unit_test.go +++ b/cmd/setup_unit_test.go @@ -316,7 +316,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... +Trying to query your username given the provided token... Unable to make a query against the GraphQL API, please check your settings. `, tempSettings.Config.Path))) }) From dd2cc2d5601f2b86fca545adf033770be6899839 Mon Sep 17 00:00:00 2001 From: iynere Date: Wed, 10 Apr 2019 15:25:45 -0400 Subject: [PATCH 6/9] ugh again --- cmd/setup_unit_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/setup_unit_test.go b/cmd/setup_unit_test.go index f031cefd8..21e11be49 100644 --- a/cmd/setup_unit_test.go +++ b/cmd/setup_unit_test.go @@ -240,7 +240,7 @@ Do you want to reset the endpoint? (default: graphql-unstable) Setup complete. Your configuration has been saved to %s. -Trying an introspection query on API to verify your setup... +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. `, tempSettings.Config.Path, `zomg`))) From 162738a361c15dcd435eddcaca12e5060cde2fd6 Mon Sep 17 00:00:00 2001 From: iynere Date: Wed, 10 Apr 2019 15:31:34 -0400 Subject: [PATCH 7/9] remove Login, doesnt exist in graphql api response --- api/api.go | 3 +-- cmd/setup.go | 4 ++-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/api/api.go b/api/api.go index 7de680004..5e7ca91dc 100644 --- a/api/api.go +++ b/api/api.go @@ -140,8 +140,7 @@ type GetOrganizationResponse struct { // WhoamiResponse type matches the data shape of the GQL response for the current user type WhoamiResponse struct { Me struct { - Login string - Name string + Name string } } diff --git a/cmd/setup.go b/cmd/setup.go index 316352ce8..cc928262f 100644 --- a/cmd/setup.go +++ b/cmd/setup.go @@ -211,9 +211,9 @@ func setupDiagnosticCheck(opts setupOptions) { if err != nil { fmt.Println("\nUnable to make a query against the GraphQL API, please check your settings.") - // If user does not have a name set in their VCS, return their login (VCS handle) instead + // If user does not have a name set in their VCS, let's just say hi :) } else if responseWho.Me.Name == "" { - fmt.Printf("Hello, %s.\n", responseWho.Me.Login) + fmt.Printf("Hello!") } else { fmt.Printf("Hello, %s.\n", responseWho.Me.Name) } From 256e77b0dd8f52c892bca0d842a0555e1acbd978 Mon Sep 17 00:00:00 2001 From: iynere Date: Thu, 11 Apr 2019 10:56:02 -0400 Subject: [PATCH 8/9] minor revisions --- cmd/setup.go | 4 ++-- cmd/setup_unit_test.go | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/cmd/setup.go b/cmd/setup.go index cc928262f..3da1ce2df 100644 --- a/cmd/setup.go +++ b/cmd/setup.go @@ -206,11 +206,11 @@ 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 { - fmt.Println("\nUnable to make a query against the GraphQL API, please check your settings.") + 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!") diff --git a/cmd/setup_unit_test.go b/cmd/setup_unit_test.go index 21e11be49..f2f367248 100644 --- a/cmd/setup_unit_test.go +++ b/cmd/setup_unit_test.go @@ -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 @@ -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 @@ -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`))) }) }) @@ -316,7 +316,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... +Trying to query our API for your profile name... Unable to make a query against the GraphQL API, please check your settings. `, tempSettings.Config.Path))) }) From fb6b1efbbadb44445f9809e5054cfa7cc14136c9 Mon Sep 17 00:00:00 2001 From: iynere Date: Thu, 11 Apr 2019 11:00:28 -0400 Subject: [PATCH 9/9] fix unit test --- cmd/setup_unit_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/setup_unit_test.go b/cmd/setup_unit_test.go index f2f367248..57dc3b67f 100644 --- a/cmd/setup_unit_test.go +++ b/cmd/setup_unit_test.go @@ -317,7 +317,7 @@ Your configuration has been saved to %s. Trying an introspection query on API to verify your setup... Ok. Trying to query our API for your profile name... -Unable to make a query against the GraphQL API, please check your settings. +Unable to query our API for your profile name, please check your settings. `, tempSettings.Config.Path))) }) })