-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #79 from RTradeLtd/testutils
Add Test Utils For Golang
- Loading branch information
Showing
5 changed files
with
54 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
// Package xtestutils provides golang testutils for developing with TemporalX | ||
package xtestutils |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package xtestutils | ||
|
||
import ( | ||
"os" | ||
"testing" | ||
) | ||
|
||
// GetXAPIAddress returns the address to used to talk to TemporalX | ||
func GetXAPIAddress(t *testing.T) string { | ||
if os.Getenv("TEST_XAPI") != "" { | ||
return os.Getenv("TEST_XAPI") | ||
} | ||
return "xapi.temporal.cloud:9090" | ||
} | ||
|
||
// GetXAPIInsecure returns whether or not to use a secure connection | ||
func GetXAPIInsecure(t *testing.T) bool { | ||
return os.Getenv("TEST_XAPI_SECURE") != "true" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package xtestutils | ||
|
||
import ( | ||
"os" | ||
"testing" | ||
) | ||
|
||
func TestGetXAPIAddress(t *testing.T) { | ||
if addr := GetXAPIAddress(t); addr != "xapi.temporal.cloud:9090" { | ||
t.Fatal("bad address") | ||
} | ||
if err := os.Setenv("TEST_XAPI", "xxapi.temporal.cloud:9090"); err != nil { | ||
t.Fatal(err) | ||
} | ||
if addr := GetXAPIAddress(t); addr != "xxapi.temporal.cloud:9090" { | ||
t.Fatal("bad address") | ||
} | ||
} | ||
|
||
func TestXAPISecure(t *testing.T) { | ||
if !GetXAPIInsecure(t) { | ||
t.Fatal("should be true") | ||
} | ||
if err := os.Setenv("TEST_XAPI_SECURE", "true"); err != nil { | ||
t.Fatal(err) | ||
} | ||
if GetXAPIInsecure(t) { | ||
t.Fatal("should be false") | ||
} | ||
} |