github.com/goplus/yap@v0.8.1/ytest/demo/_example/example_ytest.gox (about) 1 host "https://example.com", "http://localhost:8080" 2 testauth := oauth2("...") 3 4 DefaultHeader.set "User-Agent", "yaptest/0.7" 5 6 run "urlWithVar", => { 7 id := "123" 8 get "https://example.com/p/${id}" 9 ret 10 echo "code:", resp.code 11 echo "body:", resp.body 12 } 13 14 run "matchWithVar", => { 15 code := Var(int) 16 id := "123" 17 get "https://example.com/p/${id}" 18 ret code 19 echo "code:", code 20 match code, 200 21 } 22 23 run "postWithAuth", => { 24 id := "123" 25 title := "title" 26 author := "author" 27 post "https://example.com/p/${id}" 28 auth testauth 29 json { 30 "title": title, 31 "author": author, 32 } 33 ret 200 # match resp.code, 200 34 echo "body:", resp.body 35 } 36 37 run "matchJsonObject", => { 38 title := Var(string) 39 author := Var(string) 40 id := "123" 41 get "https://example.com/p/${id}" 42 ret 200 43 json { 44 "title": title, 45 "author": author, 46 } 47 echo "title:", title 48 echo "author:", author 49 }