Skip to content

Commit

Permalink
Merge pull request eriklupander#1 from retgits/update-random
Browse files Browse the repository at this point in the history
fix: add rand seed
  • Loading branch information
retgits authored Apr 7, 2020
2 parents 2139447 + d8645f1 commit 70458e9
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions internal/pkg/action/httpreq.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,18 @@ SOFTWARE.
package action

import (
"github.com/eriklupander/gotling/internal/pkg/result"
"github.com/eriklupander/gotling/internal/pkg/runtime"
"github.com/eriklupander/gotling/internal/pkg/testdef"
"github.com/eriklupander/gotling/internal/pkg/util"
"io/ioutil"
"log"
"math/rand"
"net/http"
"strings"
"time"

"github.com/eriklupander/gotling/internal/pkg/result"
"github.com/eriklupander/gotling/internal/pkg/runtime"
"github.com/eriklupander/gotling/internal/pkg/testdef"
"github.com/eriklupander/gotling/internal/pkg/util"

//"fmt"
"gopkg.in/xmlpath.v2"
//"github.com/NodePrime/jsonpath"
Expand Down Expand Up @@ -227,6 +229,7 @@ func passResultIntoSessionMap(resultsArray []string, httpAction HttpAction, sess
break
case testdef.RANDOM:
if resultCount > 1 {
rand.Seed(time.Now().UnixNano())
sessionMap[httpAction.ResponseHandler.Variable] = resultsArray[rand.Intn(resultCount-1)]
} else {
sessionMap[httpAction.ResponseHandler.Variable] = resultsArray[0]
Expand Down

0 comments on commit 70458e9

Please sign in to comment.