all repos — min @ 1ee08fd0de6b063d5bb0db373ed3abdbd2d0f307

A small but practical concatenative programming language.

tests/http.min

 1
 2
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
'test load
'test import

"http" describe
  
  "http://postman-echo.com" :url

  ("$1/get" (url) => % get-content from-json /headers /user-agent  "min http-module/$1" (version) => % ==) assert

  ("$1/get?test=Hello!" (url) => % "tests/test1.json" :file file download file fread from-json /args /test "Hello!" ==) assert
  "tests/test1.json" rm

  (
    {} (
      ("$1/get" (url) => % %url) 
      ("GET" %method)
      ({"it-it" :Accept-Language} %headers)
      (request)
    ) tap /body from-json /headers /accept-language "it-it" ==
  ) assert

  (
    {} (
      ("$1/put" (url) => % %url) 
      ("PUT" %method)
      ({} to-json %body)
      (request)
    ) tap /body from-json /data {} ==
  ) assert

  (
    {} (
      ("$1/post" (url) => % %url) 
      ("POST" %method)
      ({"post" :test} to-json %body)
      (request)
    ) tap /headers /content-type "^application/json" match
  ) assert

  (
    {} (
      ("$1/patch" (url) => % %url) 
      ("PATCH" %method)
      ({} to-json %body)
      (request)
    ) tap /body from-json /data {} ==
  ) assert

  (
    {} (
      ("$1/delete" (url) => % %url) 
      ("DELETE" %method)
      (request)
    ) tap /body from-json /url "$1/delete" (url) => % ==
  ) assert

  report
  clear-stack