From 74ff217c7e8855c5ccf6dbc69cee0823cd65ee1b Mon Sep 17 00:00:00 2001 From: skyblue Date: Mon, 31 Mar 2014 13:30:32 +0800 Subject: [PATCH 1/3] add tests --- .gitignore | 13 ++++--------- tests/.travel.yml | 9 +++++++++ tests/README.md | 14 ++++++++++++++ tests/pyquick/test_index_rest.py | 13 +++++++++++++ 4 files changed, 40 insertions(+), 9 deletions(-) create mode 100644 tests/.travel.yml create mode 100644 tests/README.md create mode 100644 tests/pyquick/test_index_rest.py diff --git a/.gitignore b/.gitignore index cd9109b8db..158421d04a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,9 +1,3 @@ -<<<<<<< HEAD - - -gogs -*.exe -*.exe~ .DS_Store *.db *.log @@ -14,8 +8,6 @@ data/ *.iml public/img/avatar/ -======= ->>>>>>> b4db9f67548a41922f1b337daf9c9d2b975b55c4 # Compiled Object files, Static and Dynamic libs (Shared Objects) *.o *.a @@ -37,4 +29,7 @@ _cgo_export.* _testmain.go -*.exe \ No newline at end of file +*.exe +*.exe~ +gogs +__pycache__ diff --git a/tests/.travel.yml b/tests/.travel.yml new file mode 100644 index 0000000000..820621b283 --- /dev/null +++ b/tests/.travel.yml @@ -0,0 +1,9 @@ +command: python -m pytest {} +include: ^test_.*\.py$ +path: ./ +depth: 1 +verbose: true +timeout: 1m +reload: false +html: test.html +notify: [] diff --git a/tests/README.md b/tests/README.md new file mode 100644 index 0000000000..aba7d388e5 --- /dev/null +++ b/tests/README.md @@ -0,0 +1,14 @@ +## gogs test + +this is for developers + +## prepare environment + # install python dependency + pip install pytest + # install basic test tool + go get -u github.com/shxsun/travelexec + # start gogs server + gogs web + +## start test + travelexec diff --git a/tests/pyquick/test_index_rest.py b/tests/pyquick/test_index_rest.py new file mode 100644 index 0000000000..be0bf18300 --- /dev/null +++ b/tests/pyquick/test_index_rest.py @@ -0,0 +1,13 @@ +#!/usr/bin/env python +# coding: utf-8 +# +# + +import requests + +HOST = 'http://localhost:3000' + +def test_index_get(): + r = requests.get(HOST + '/') + assert r.status_code == 200 + From 587e6d80890f9e679b13a1511dab6635fd520775 Mon Sep 17 00:00:00 2001 From: skyblue Date: Mon, 31 Mar 2014 15:54:15 +0800 Subject: [PATCH 2/3] add start.sh+bat --- .gobuild.yml | 4 +++- start.bat | 2 ++ start.sh | 6 ++++++ web.go | 3 ++- 4 files changed, 13 insertions(+), 2 deletions(-) create mode 100644 start.bat create mode 100755 start.sh diff --git a/.gobuild.yml b/.gobuild.yml index 78a38f2d31..d5bc6606c1 100644 --- a/.gobuild.yml +++ b/.gobuild.yml @@ -5,4 +5,6 @@ filesets: - conf - LICENSE - README.md - - README_ZH.md \ No newline at end of file + - README_ZH.md + - start.bat + - start.sh diff --git a/start.bat b/start.bat new file mode 100644 index 0000000000..02972b92da --- /dev/null +++ b/start.bat @@ -0,0 +1,2 @@ +@echo off +gogs.exe web diff --git a/start.sh b/start.sh new file mode 100755 index 0000000000..331d340cda --- /dev/null +++ b/start.sh @@ -0,0 +1,6 @@ +#!/bin/bash - +# +# start gogs web +# +cd "$(dirname $0)" +./gogs web diff --git a/web.go b/web.go index 412dcb622b..cdec9232a9 100644 --- a/web.go +++ b/web.go @@ -160,6 +160,7 @@ func runWeb(*cli.Context) { base.Cfg.MustValue("server", "HTTP_PORT", "3000")) log.Info("Listen: %s", listenAddr) if err := http.ListenAndServe(listenAddr, m); err != nil { - log.Critical(err.Error()) + fmt.Println(err.Error()) + //log.Critical(err.Error()) // not working now } } From 9acc1c33be76b05231ec3a5a222af02484689974 Mon Sep 17 00:00:00 2001 From: skyblue Date: Mon, 31 Mar 2014 16:24:58 +0800 Subject: [PATCH 3/3] add go functest --- tests/.travel.yml | 4 ++-- tests/README.md | 3 --- tests/default_test.go | 17 +++++++++++++++++ tests/pyquick/test_index_rest.py | 13 ------------- 4 files changed, 19 insertions(+), 18 deletions(-) create mode 100644 tests/default_test.go delete mode 100644 tests/pyquick/test_index_rest.py diff --git a/tests/.travel.yml b/tests/.travel.yml index 820621b283..09a5752bfb 100644 --- a/tests/.travel.yml +++ b/tests/.travel.yml @@ -1,5 +1,5 @@ -command: python -m pytest {} -include: ^test_.*\.py$ +command: go test -v {} +include: ^.+_test\.go$ path: ./ depth: 1 verbose: true diff --git a/tests/README.md b/tests/README.md index aba7d388e5..98693257f2 100644 --- a/tests/README.md +++ b/tests/README.md @@ -3,9 +3,6 @@ this is for developers ## prepare environment - # install python dependency - pip install pytest - # install basic test tool go get -u github.com/shxsun/travelexec # start gogs server gogs web diff --git a/tests/default_test.go b/tests/default_test.go new file mode 100644 index 0000000000..d6f3a03be6 --- /dev/null +++ b/tests/default_test.go @@ -0,0 +1,17 @@ +package test + +import ( + "net/http" + "testing" +) + +func TestMain(t *testing.T) { + r, err := http.Get("http://localhost:3000/") + if err != nil { + t.Fatal(err) + } + defer r.Body.Close() + if r.StatusCode != http.StatusOK { + t.Error(r.StatusCode) + } +} diff --git a/tests/pyquick/test_index_rest.py b/tests/pyquick/test_index_rest.py deleted file mode 100644 index be0bf18300..0000000000 --- a/tests/pyquick/test_index_rest.py +++ /dev/null @@ -1,13 +0,0 @@ -#!/usr/bin/env python -# coding: utf-8 -# -# - -import requests - -HOST = 'http://localhost:3000' - -def test_index_get(): - r = requests.get(HOST + '/') - assert r.status_code == 200 -