Skip to content

Commit

Permalink
one place tst should be mapped to test
Browse files Browse the repository at this point in the history
  • Loading branch information
nad2000 committed Dec 4, 2019
1 parent 8fc8e36 commit 82386a5
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
12 changes: 10 additions & 2 deletions handler/common.go
Expand Up @@ -51,15 +51,23 @@ var (
qualifications map[string]string
)

func iif(cond bool, truePart, falsePart string) string {
if cond {
return truePart
}
return falsePart
}

func init() {
godotenv.Load()

env = os.Getenv("ENV")
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"
Expand Down
5 changes: 5 additions & 0 deletions handler/handler_internal_test.go
Expand Up @@ -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(`{
Expand Down

0 comments on commit 82386a5

Please sign in to comment.