Skip to content

Commit 27d7f1d

Browse files
authored
Merge pull request #487 from rainforestapp/RF-22799-allow-empty-fragment-in-custom-url
Allow creation of temporary environment using custom-url containing empty fragment.
2 parents d6624ff + 1212393 commit 27d7f1d

File tree

2 files changed

+21
-4
lines changed

2 files changed

+21
-4
lines changed

runner.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -437,7 +437,7 @@ func (r *runner) makeRunParams(c cliContext, localTests []*rainforest.RFTest, br
437437
}
438438

439439
var environment *rainforest.Environment
440-
environment, err = r.client.CreateTemporaryEnvironment(description, customURL.String(), webhookURL.String())
440+
environment, err = r.client.CreateTemporaryEnvironment(description, customURLParam, webhookParam)
441441
if err != nil {
442442
return rainforest.RunParams{}, err
443443
}

runner_test.go

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,9 @@ type fakeRunnerClient struct {
8282
mu sync.Mutex
8383
// "inherit" from RF API
8484
testRfAPI
85+
86+
temporaryEnvironmentURL string
87+
temporaryEnvironmentWebhook string
8588
}
8689

8790
func (r *fakeRunnerClient) CheckRunStatus(runID int) (*rainforest.RunStatus, error) {
@@ -117,6 +120,8 @@ func (r *fakeRunnerClient) UpdateTest(t *rainforest.RFTest, branchID int) error
117120
}
118121

119122
func (r *fakeRunnerClient) CreateTemporaryEnvironment(n string, s string, t string) (*rainforest.Environment, error) {
123+
r.temporaryEnvironmentURL = s
124+
r.temporaryEnvironmentWebhook = t
120125
return &r.environment, nil
121126
}
122127

@@ -219,8 +224,8 @@ func TestMakeRunParams(t *testing.T) {
219224
},
220225
{
221226
mappings: map[string]interface{}{
222-
"custom-url": "https://www.rainforestqa.com",
223-
"webhook": "https://www.rainforestqa.com/endpoint",
227+
"custom-url": "https://www.rainforestqa.com/foo#",
228+
"webhook": "https://www.rainforestqa.com/endpoint#",
224229
},
225230
args: cli.Args{},
226231
expected: rainforest.RunParams{
@@ -274,9 +279,21 @@ func TestMakeRunParams(t *testing.T) {
274279
c := newFakeContext(testCase.mappings, testCase.args)
275280
r := newRunner()
276281
fakeEnv := rainforest.Environment{ID: fakeEnvID, Name: "the foo environment"}
277-
r.client = &fakeRunnerClient{environment: fakeEnv}
282+
client := &fakeRunnerClient{environment: fakeEnv}
283+
r.client = client
278284
res, err := r.makeRunParams(c, nil, 0)
279285

286+
customURLParam := c.String("custom-url")
287+
webhookParam := c.String("webhook")
288+
289+
if customURLParam != "" && client.temporaryEnvironmentURL != customURLParam {
290+
t.Errorf("Expected to call CreateTemporaryEnvironment with url %#v instead got %#v", customURLParam, client.temporaryEnvironmentURL)
291+
}
292+
293+
if webhookParam != "" && client.temporaryEnvironmentWebhook != webhookParam {
294+
t.Errorf("Expected to call CreateTemporaryEnvironment with webhook %#v instead got %#v", webhookParam, client.temporaryEnvironmentWebhook)
295+
}
296+
280297
if err != nil {
281298
t.Errorf("Error trying to create params: %v", err)
282299
} else if !reflect.DeepEqual(res, testCase.expected) {

0 commit comments

Comments
 (0)