@@ -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
8790func (r * fakeRunnerClient ) CheckRunStatus (runID int ) (* rainforest.RunStatus , error ) {
@@ -117,6 +120,8 @@ func (r *fakeRunnerClient) UpdateTest(t *rainforest.RFTest, branchID int) error
117120}
118121
119122func (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