matryer / silk

Markdown based document-driven RESTful API testing.
http://silktest.org/
GNU General Public License v2.0
940 stars 69 forks source link

Support for multipart multipart/form-data and file upload #22

Open mantishK opened 8 years ago

mantishK commented 8 years ago

Support multipart data and uploading file as a form parameter in POST and PUT methods. There can be a folder that contains all the files that will be uploaded while testing, this path can be set as an argument while running silk. The names of the file mentioned in the markdown could be relative to this folder. We can add a comment after the field that the filed is a file field and it's value is a file path.

name: Mat
CV: CV/mat-cv.pdf // file
matryer commented 8 years ago

I think a link to the file will be good.

[field_name](/path/to/file)

How does that sound? It means that, when rendered, the user could even preview the file.

mantishK commented 8 years ago

It means that the files to be uploaded while testing will have to be in a repo/server and the files need to be public. This may not always be the case, correct? Also, while testing, silk will download each file and then upload them. It may consume a lot of time if there are too many files/tests. It would be great if we keep the link and have some way of overriding the base path that contains the files to be uploaded. Your thoughts?

matryer commented 8 years ago

Silk runs locally (so far) so the files would be nearby, I think they would only get uploaded, and probably to a local server. I think selective test running will help people avoid long-running tests, as would have to be the case anyway.

mantishK commented 8 years ago

If we are giving local file path, then there are no issues as far as the working of silk is considered. Wouldn't it be hard to share the test docs to others? By hard, I mean, due to local path, the links may not open on other machines.

matryer commented 8 years ago

I'm thinking you'd have this:

/tests
  /files
    image1.png
  /silk
    thumbnails.silk.md
      (would mention `../files/image1.png`)

So the files would go alongside the test files. For bigger files, a script to download the files into the correct place might be sensible, but out of scope of Silk.

How does that sound?

mantishK commented 8 years ago

Sounds good.

davidbgk commented 8 years ago

I don't know Go at all but I can test a branch and provide some feedback once the feature is implemented given that I'll need it for a project.