hofstadter-io / frisby Goto Github PK
View Code? Open in Web Editor NEWAPI testing framework inspired by frisby-js
License: MIT License
API testing framework inspired by frisby-js
License: MIT License
Hey - first up, thanks for the work on your library. We're evaluating using it and Iv'e come across an issue with the ExpectJson
api.
I have a json response that looks like this:
{
"error": "Invalid data supplied",
"fields": {
"display_name": "display_name is required",
"ends_at": "ends_at is required",
"starts_at": "starts_at is required",
"state.state": "state must be one of the following: \"active\", \"inactive\""
}
}
I'd love to be able to test this via ExpectJson("fields.state.state", "xxx")
but for obvious reasons this isn't possible.
I see two options for fixing this. One is to change the signature of the current api, which would be a backwards incompatible change: ExpectJson(expectation string, path string...)
. The other option would be to add a new method with that signature, e.g. ExpectJsonAtPath(expecation string, path string...)
.
Thoughts?
Wanted to check if you would recommend using this library, if it's actively maintained. If not what would you recommend in it's place?
Improve the TravisCI workflow to include running tests, both unit and functional
test for, and provide better error reporting for, situations where things are not there or null
When trying to match a JSON returned value which is an integer, normally I (think I) should be using:
ExpectJsonType("foobar", reflect.Int)
, but when doing this, I get an error: Expect Json "foobar" type to be "int", but got json.Number
.
Should be able to set request values, such as headers, which would persist to any subsequent request
go version go1.6.2 darwin/amd64
the mozilla vendored version of go-simplejson is preventing usage
sinewave:gopath robmurtha$ go get -u github.com/verdverm/frisby
# github.com/verdverm/frisby
src/github.com/verdverm/frisby/expect.go:221: cannot use json (type *"github.com/mozillazg/request/vendor/github.com/bitly/go-simplejson".Json) as type *"github.com/bitly/go-simplejson".Json in argument to foo
same issue when using gvt
Testing needs to be upgraded...
Specific known errors
I can't seem to find a way to do ExpectJson
with a path like payload[0].state
or payload.[0].state
, and based on the code i don't think it's supported.
Do you think it would be possible to update the way that paths are looked up from simp_json.GetPath
to a loop that evaluates each of the keys and checks to see if there's is an index lookup in it?
Currently we have:
path_items := strings.Split(path, ".")
simp_json = simp_json.GetPath(path_items...)
We could look at something like (exclude the psuedo code, I haven't tested this):
for _, pathItem := range strings.Split(path, ".") {
matches := regexp.MustCompile("^\\[([0-9]+)\\]$").FindStringSubmatch(pathItem)
if len(matches) < 2 {
simp_json = simp_json.Get(pathItem)
} else {
index, _ := strconv.Atoi(matches[1])
simp_json = simp_json.GetIndex(index)
}
}
There should be global accounting so that the user doesn't have to call PrintReport,
verbose mode would be nice and maybe print a list of accumulated errors
Golang's http library requires you to explicitly close the response's body object in order to avoid resource leaks and to allow for connection re-use.
https://golang.org/pkg/net/http/#pkg-overview
As far as I can tell Frisby doesn't do this, which can start to cause problems if you're running large numbers of tests (running out of sockets/file descriptors, slow run time, etc).
SetCookie,SetData,SetParam always panic because it's nil
would be a nice-to-have function, but can be accomplished with the AfterJson currently
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.