diff options
author | Ethan Koenig <etk39@cornell.edu> | 2017-04-25 03:24:51 -0400 |
---|---|---|
committer | Lunny Xiao <xiaolunwen@gmail.com> | 2017-04-25 15:24:51 +0800 |
commit | c58708d3eedb352bb277feb2c12bb1652a8a58b7 (patch) | |
tree | 97aeed6a13031618baa7d67185b04faea506da38 /integrations/signup_test.go | |
parent | 3012971e92b79683178a286511c091fb31ee90f6 (diff) | |
download | gitea-c58708d3eedb352bb277feb2c12bb1652a8a58b7.tar.gz gitea-c58708d3eedb352bb277feb2c12bb1652a8a58b7.zip |
Integration test framework (#1290)
* Integration test framework
* udpate drone sign
* Formatting fixes and move router.go to routers/
* update sign for drone
Diffstat (limited to 'integrations/signup_test.go')
-rw-r--r-- | integrations/signup_test.go | 50 |
1 files changed, 28 insertions, 22 deletions
diff --git a/integrations/signup_test.go b/integrations/signup_test.go index 55ae64c373..7d8f27332e 100644 --- a/integrations/signup_test.go +++ b/integrations/signup_test.go @@ -2,34 +2,40 @@ // Use of this source code is governed by a MIT-style // license that can be found in the LICENSE file. -package integration +package integrations import ( - "os" + "bytes" + "net/http" + "net/url" "testing" - "code.gitea.io/gitea/integrations/internal/utils" -) - -var signupFormSample map[string][]string = map[string][]string{ - "Name": {"tester"}, - "Email": {"user1@example.com"}, - "Passwd": {"12345678"}, -} + "code.gitea.io/gitea/models" + "code.gitea.io/gitea/modules/setting" -func signup(t *utils.T) error { - return utils.GetAndPost("http://:"+ServerHTTPPort+"/user/sign_up", signupFormSample) -} + "github.com/stretchr/testify/assert" +) func TestSignup(t *testing.T) { - conf := utils.Config{ - Program: "../gitea", - WorkDir: "", - Args: []string{"web", "--port", ServerHTTPPort}, - LogFile: os.Stderr, - } + assert.NoError(t, models.LoadFixtures()) + setting.Service.EnableCaptcha = false + + req, err := http.NewRequest("POST", "/user/sign_up", + bytes.NewBufferString(url.Values{ + "user_name": []string{"exampleUser"}, + "email": []string{"exampleUser@example.com"}, + "password": []string{"examplePassword"}, + "retype": []string{"examplePassword"}, + }.Encode()), + ) + assert.NoError(t, err) + req.Header.Add("Content-Type", "application/x-www-form-urlencoded") + resp := MakeRequest(req) + assert.EqualValues(t, http.StatusFound, resp.HeaderCode) - if err := utils.New(t, &conf).RunTest(install, signup); err != nil { - t.Fatal(err) - } + // should be able to view new user's page + req, err = http.NewRequest("GET", "/exampleUser", nil) + assert.NoError(t, err) + resp = MakeRequest(req) + assert.EqualValues(t, http.StatusOK, resp.HeaderCode) } |