From 82386a58f28974c1832630085666c5b64555f51c Mon Sep 17 00:00:00 2001 From: Rad Cirskis Date: Wed, 4 Dec 2019 16:35:07 +1300 Subject: [PATCH] one place tst should be mapped to test --- handler/common.go | 12 ++++++++++-- handler/handler_internal_test.go | 5 +++++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/handler/common.go b/handler/common.go index a59e74c..f0b96d7 100644 --- a/handler/common.go +++ b/handler/common.go @@ -51,6 +51,13 @@ var ( qualifications map[string]string ) +func iif(cond bool, truePart, falsePart string) string { + if cond { + return truePart + } + return falsePart +} + func init() { godotenv.Load() @@ -58,8 +65,9 @@ func init() { verboseEnv := os.Getenv("VERBOSE") verbose = verboseEnv != "" && verboseEnv != "n" && verboseEnv != "0" && verboseEnv != "false" if env != "" && env != "prd" { - APIBaseURL = "https://api." + env + ".auckland.ac.nz/service" - OHBaseURL = "https://" + env + ".orcidhub.org.nz" + var e = iif(env == "tst", "test", env) + APIBaseURL = "https://api." + e + ".auckland.ac.nz/service" + OHBaseURL = "https://" + e + ".orcidhub.org.nz" } else { APIBaseURL = "https://api.auckland.ac.nz/service" OHBaseURL = "https://orcidhub.org.nz" diff --git a/handler/handler_internal_test.go b/handler/handler_internal_test.go index e64e0fc..df142e6 100644 --- a/handler/handler_internal_test.go +++ b/handler/handler_internal_test.go @@ -401,6 +401,11 @@ func testHealthCheck(t *testing.T) { assert.NotNil(t, err) } +func TestIif(t *testing.T) { + assert.Equal(t, "T", iif(true, "T", "F")) + assert.Equal(t, "F", iif(false, "T", "F")) +} + func TestIdentityGetORCID(t *testing.T) { var id Identity json.Unmarshal([]byte(`{