Skip to content

Commit 399d9de

Browse files
committed
Removed use of Environment from ablytest and sandbox test utils, updated
tests accordingly
1 parent 41049b4 commit 399d9de

File tree

3 files changed

+10
-15
lines changed

3 files changed

+10
-15
lines changed

ably/rest_channel_integration_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ func TestRESTChannel(t *testing.T) {
142142
}
143143

144144
func TestIdempotentPublishing(t *testing.T) {
145-
app, err := ablytest.NewSandboxWithEndpoint(nil, ablytest.Endpoint, ablytest.Environment)
145+
app, err := ablytest.NewSandboxWithEndpoint(nil, ablytest.Endpoint)
146146
assert.NoError(t, err)
147147
defer app.Close()
148148
options := app.Options(ably.WithIdempotentRESTPublishing(true))
@@ -295,7 +295,7 @@ func TestIdempotentPublishing(t *testing.T) {
295295
}
296296

297297
func TestIdempotent_retry(t *testing.T) {
298-
app, err := ablytest.NewSandboxWithEndpoint(nil, ablytest.Endpoint, ablytest.Environment)
298+
app, err := ablytest.NewSandboxWithEndpoint(nil, ablytest.Endpoint)
299299
assert.NoError(t, err)
300300
defer app.Close()
301301
randomStr, err := ablyutil.BaseID()

ablytest/ablytest.go

+2-3
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ import (
1717
var Timeout = 30 * time.Second
1818
var NoBinaryProtocol bool
1919
var DefaultLogLevel = ably.LogNone
20-
var Environment = "sandbox"
2120
var Endpoint = "nonprod:sandbox"
2221

2322
func nonil(err ...error) error {
@@ -41,8 +40,8 @@ func init() {
4140
if n, err := strconv.Atoi(os.Getenv("ABLY_LOGLEVEL")); err == nil {
4241
DefaultLogLevel = ably.LogLevel(n)
4342
}
44-
if s := os.Getenv("ABLY_ENV"); s != "" {
45-
Environment = s
43+
if s := os.Getenv("ABLY_ENDPOINT"); s != "" {
44+
Endpoint = s
4645
}
4746
}
4847

ablytest/sandbox.go

+6-10
Original file line numberDiff line numberDiff line change
@@ -105,9 +105,6 @@ type Sandbox struct {
105105
// Endpoint is the hostname to connect to
106106
Endpoint string
107107

108-
// Environment is used in auth parameters
109-
Environment string
110-
111108
client *http.Client
112109
}
113110

@@ -138,15 +135,14 @@ func MustSandbox(config *Config) *Sandbox {
138135
}
139136

140137
func NewSandbox(config *Config) (*Sandbox, error) {
141-
return NewSandboxWithEndpoint(config, Endpoint, Environment)
138+
return NewSandboxWithEndpoint(config, Endpoint)
142139
}
143140

144-
func NewSandboxWithEndpoint(config *Config, endpoint, environment string) (*Sandbox, error) {
141+
func NewSandboxWithEndpoint(config *Config, endpoint string) (*Sandbox, error) {
145142
app := &Sandbox{
146-
Config: config,
147-
Endpoint: endpoint,
148-
Environment: environment,
149-
client: NewHTTPClient(),
143+
Config: config,
144+
Endpoint: endpoint,
145+
client: NewHTTPClient(),
150146
}
151147
if app.Config == nil {
152148
app.Config = DefaultConfig()
@@ -282,7 +278,7 @@ var CREATE_JWT_URL string = "https://echo.ably.io/createJWT"
282278
func (app *Sandbox) GetJwtAuthParams(expiresIn time.Duration, invalid bool) url.Values {
283279
key, secret := app.KeyParts()
284280
authParams := url.Values{}
285-
authParams.Add("environment", app.Environment)
281+
authParams.Add("endpoint", app.Endpoint)
286282
authParams.Add("returnType", "jwt")
287283
authParams.Add("keyName", key)
288284
if invalid {

0 commit comments

Comments
 (0)