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/version_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/version_test.go')
-rw-r--r-- | integrations/version_test.go | 78 |
1 files changed, 15 insertions, 63 deletions
diff --git a/integrations/version_test.go b/integrations/version_test.go index beda5c3ab7..58568e22fe 100644 --- a/integrations/version_test.go +++ b/integrations/version_test.go @@ -2,81 +2,33 @@ // 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 ( + "bytes" "encoding/json" - "fmt" - "log" "net/http" - "os" - "os/exec" - "path/filepath" - "strings" "testing" - "code.gitea.io/gitea/integrations/internal/utils" + "code.gitea.io/gitea/models" + "code.gitea.io/gitea/modules/setting" "code.gitea.io/sdk/gitea" "github.com/stretchr/testify/assert" ) -func version(t *utils.T) error { - var err error - - path, err := filepath.Abs(t.Config.Program) - if err != nil { - return err - } - - cmd := exec.Command(path, "--version") - out, err := cmd.Output() - if err != nil { - return err - } - - fields := strings.Fields(string(out)) - if !strings.HasPrefix(string(out), "Gitea version") { - return fmt.Errorf("unexpected version string '%s' of the gitea executable", out) - } - - expected := fields[2] - - var r *http.Response - r, err = http.Get("http://:" + ServerHTTPPort + "/api/v1/version") - if err != nil { - return err - } - defer r.Body.Close() - - if r.StatusCode != http.StatusOK { - return fmt.Errorf("'/api/v1/version': %s\n", r.Status) - } - - var v gitea.ServerVersion - - dec := json.NewDecoder(r.Body) - if err := dec.Decode(&v); err != nil { - return err - } - - actual := v.Version - - log.Printf("Actual: \"%s\" Expected: \"%s\"\n", actual, expected) - assert.Equal(t, expected, actual) +func TestVersion(t *testing.T) { + assert.NoError(t, models.LoadFixtures()) - return nil -} + setting.AppVer = "1.1.0+dev" + req, err := http.NewRequest("GET", "/api/v1/version", nil) + assert.NoError(t, err) + resp := MakeRequest(req) -func TestVersion(t *testing.T) { - conf := utils.Config{ - Program: "../gitea", - WorkDir: "", - Args: []string{"web", "--port", ServerHTTPPort}, - LogFile: os.Stderr, - } + var version gitea.ServerVersion + decoder := json.NewDecoder(bytes.NewBuffer(resp.Body)) + assert.NoError(t, decoder.Decode(&version)) - if err := utils.New(t, &conf).RunTest(install, version); err != nil { - t.Fatal(err) - } + assert.EqualValues(t, http.StatusOK, resp.HeaderCode) + assert.Equal(t, setting.AppVer, string(version.Version)) } |