Skip to content

Commit

Permalink
fix: fetches tcs of an app without any filter (#177)
Browse files Browse the repository at this point in the history
fetch function makes a get call to keploy API server and returns tcs for an app without any tcsType
filter

Signed-off-by: re-Tick <jain.ritik.1001@gmail.com>
  • Loading branch information
re-Tick authored Mar 21, 2023
1 parent ec714e1 commit 9d4331d
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ require (
github.com/jhump/protoreflect v1.14.0
github.com/lestrrat-go/jwx v1.2.25
github.com/valyala/fasthttp v1.40.0
go.keploy.io/server v0.8.0
go.keploy.io/server v0.8.2
)

require (
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -368,8 +368,8 @@ go.keploy.io/server v0.5.6/go.mod h1:/wHYlepZLITJ+MsYnRfRED9K/ENset2JhfzeAqSGnV0
go.keploy.io/server v0.7.8/go.mod h1:Xm0Zzt2iBRrvoDY7fBMm8M+geV+ZlkknbqKRVjC3K0I=
go.keploy.io/server v0.7.12/go.mod h1:ch4rD1NCgtxozDHD9yVk+sLHWz5HgefOqrgEdEIgfBQ=
go.keploy.io/server v0.7.20/go.mod h1:cu/y7NQ8Io1OP2BfMtfFQugYd/UanRvDWpzcyulx/Qo=
go.keploy.io/server v0.8.0 h1:AN7j3wNoXAPklYu+5KwMZOg57M3eYinI0bOTrhHho7s=
go.keploy.io/server v0.8.0/go.mod h1:NdVsySEK6BCZdqeqY5eCIMJL01VmfvPIvjxBpBUcsQE=
go.keploy.io/server v0.8.2 h1:QN+UmD3NQw4gqPKUQPY9X16alFU6XgNa+UpGsSrvcH8=
go.keploy.io/server v0.8.2/go.mod h1:NdVsySEK6BCZdqeqY5eCIMJL01VmfvPIvjxBpBUcsQE=
go.mongodb.org/mongo-driver v1.8.3 h1:TDKlTkGDKm9kkJVUOAXDK5/fkqKHJVwYQSpoRfB43R4=
go.mongodb.org/mongo-driver v1.8.3/go.mod h1:0sQWfOeY63QTntERDJJ/0SuKK0T1uVSgKCuAROlKEPY=
go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU=
Expand Down
15 changes: 8 additions & 7 deletions keploy/keploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,8 @@ type AppConfig struct {
type Filter struct {
AcceptUrlRegex string
HeaderRegex []string
Remove []string
Replace map[string]string
Remove []string
Replace map[string]string
RejectUrlRegex []string
}

Expand Down Expand Up @@ -285,7 +285,7 @@ func (k *Keploy) PutRespGrpc(id string, resp GrpcResp) {
// Capture will capture request, response and output of external dependencies by making Call to keploy server.
func (k *Keploy) Capture(req regression.TestCaseReq) {
// req.Path, _ = os.Getwd()
req.Remove = k.cfg.App.Filter.Remove //Setting the Remove field from config
req.Remove = k.cfg.App.Filter.Remove //Setting the Remove field from config
req.Replace = k.cfg.App.Filter.Replace //Setting the Replace field from config
go k.put(req)
}
Expand All @@ -295,8 +295,7 @@ func (k *Keploy) Test() {
// fetch test cases from web server and save to memory
k.Log.Info("test starting in " + k.cfg.App.Delay.String())
time.Sleep(k.cfg.App.Delay)
tcs := k.fetch(models.HTTP)
tcs = append(tcs, k.fetch(models.GRPC_EXPORT)...)
tcs := k.fetch()
total := len(tcs)

// start a http test run
Expand Down Expand Up @@ -756,12 +755,14 @@ func (k *Keploy) newGet(url string) ([]byte, error) {
return body, nil
}

func (k *Keploy) fetch(reqType models.Kind) []models.TestCase {
// fetch makes a get request to keploy API server and returns array of testcases
func (k *Keploy) fetch() []models.TestCase {

var tcs []models.TestCase = []models.TestCase{}
pageSize := 25

for i := 0; ; i += pageSize {
url := fmt.Sprintf("%s/regression/testcase?app=%s&offset=%d&limit=%d&testCasePath=%s&mockPath=%s&reqType=%s", k.cfg.Server.URL, k.cfg.App.Name, i, 25, k.cfg.App.TestPath, k.cfg.App.MockPath, reqType)
url := fmt.Sprintf("%s/regression/testcase?app=%s&offset=%d&limit=%d&testCasePath=%s&mockPath=%s", k.cfg.Server.URL, k.cfg.App.Name, i, 25, k.cfg.App.TestPath, k.cfg.App.MockPath)

req, err := http.NewRequest("GET", url, http.NoBody)
if err != nil {
Expand Down

0 comments on commit 9d4331d

Please sign in to comment.