feat: add test folder with user functional testing

master
fbonhomm 2019-08-24 20:52:12 +02:00
parent 60974957b7
commit 67ec0a8a7b
2 changed files with 70 additions and 0 deletions

View File

@ -0,0 +1,34 @@
/**
* Created by fbonhomm
* Email: flo-github@outlook.fr
* Licence: MIT
*/
package fonctional
import (
"fmt"
"io/ioutil"
"log"
"net/http"
"testing"
)
// TestUserPost
func TestGetIdPost(t *testing.T) {
resp, err := http.Get("http://localhost:3000/users/10")
if err != nil {
log.Panic(err)
}
body, err := ioutil.ReadAll(resp.Body)
if nil != err {
log.Panic(err)
}
fmt.Println(string(body[:]))
resp.Body.Close()
}

View File

@ -0,0 +1,36 @@
/**
* Created by fbonhomm
* Email: flo-github@outlook.fr
* Licence: MIT
*/
package fonctional
import (
"fmt"
"io/ioutil"
"log"
"net/http"
"net/url"
"testing"
)
// TestUserPost
func TestUserPost(t *testing.T) {
resp, err := http.PostForm("http://localhost:3000/users", url.Values{
"name": {"test"}, "email": {"example@test.com"}, "password": {"12345678"}})
if err != nil {
log.Panic(err)
}
body, err := ioutil.ReadAll(resp.Body)
if nil != err {
log.Panic(err)
}
fmt.Println(string(body[:]))
resp.Body.Close()
}