From 6f491e70ae177df8427bb54ce7d50398dc16b283 Mon Sep 17 00:00:00 2001 From: 6543 <6543@noreply.gitea.io> Date: Sun, 26 Jan 2020 07:22:57 +0000 Subject: [PATCH] [Makefile] Add "test-instance"; Add "help" (#231) PASSWORD_COMPLEXITY = off fix test Makefile: add "test-instance" (start a gitea instance for test) and add a help menue Fix ListIssue Functions (now respect ListIssueOption's) (#225) fix test add Test add more test cases and fix nice log add Issue Tests impruve more Repo Tests and mv createTestRepo introduce "createTestRepo" a standad func to create a repo for testing add workaround * Update Dates * Fix ListIssueOption Fix ListRepoPullRequests (#219) add ToDo notice add ListRepoPullRequests TEST remove useless drone config emtrys fmt ping CI add new Options from PR #217 use query params Add some PR list options (#217) Empty Commit Add enums Add some PR list options Add test framework (#227) [Extend] StopWatch struct & functions (#211) add StopWatch struct & functions [Add] reaction struct and functions (#213) add struct and functions Co-authored-by: 6543 <6543@obermui.de> Reviewed-by: Andrew Thornton Reviewed-by: techknowlogick [Add] issue Un-/Subscription function (#214) fix lint add issue subscription function Co-authored-by: 6543 <6543@obermui.de> Reviewed-by: Andrew Thornton Reviewed-by: techknowlogick [Add] GetBlob (#212) fix header from PR 206 add GetBlob Co-authored-by: 6543 <6543@obermui.de> Reviewed-by: Lunny Xiao Reviewed-by: Andrew Thornton Co-authored-by: 6543 <6543@obermui.de> Reviewed-by: Andrew Thornton Reviewed-by: techknowlogick Co-authored-by: jolheiser Co-authored-by: techknowlogick Co-authored-by: 6543 <6543@noreply.gitea.io> Reviewed-by: techknowlogick Reviewed-by: 6543 <6543@noreply.gitea.io> Add test framework (#227) Co-authored-by: 6543 <6543@obermui.de> Co-authored-by: John Olheiser Co-authored-by: techknowlogick Reviewed-by: techknowlogick Reviewed-by: Lunny Xiao Add some PR list options (#217) Empty Commit Add enums Add some PR list options Add test framework (#227) [Extend] StopWatch struct & functions (#211) add StopWatch struct & functions [Add] reaction struct and functions (#213) add struct and functions Co-authored-by: 6543 <6543@obermui.de> Reviewed-by: Andrew Thornton Reviewed-by: techknowlogick [Add] issue Un-/Subscription function (#214) fix lint add issue subscription function Co-authored-by: 6543 <6543@obermui.de> Reviewed-by: Andrew Thornton Reviewed-by: techknowlogick [Add] GetBlob (#212) fix header from PR 206 add GetBlob Co-authored-by: 6543 <6543@obermui.de> Reviewed-by: Lunny Xiao Reviewed-by: Andrew Thornton Co-authored-by: 6543 <6543@obermui.de> Reviewed-by: Andrew Thornton Reviewed-by: techknowlogick Co-authored-by: jolheiser Co-authored-by: techknowlogick Co-authored-by: 6543 <6543@noreply.gitea.io> Reviewed-by: techknowlogick Reviewed-by: 6543 <6543@noreply.gitea.io> Add test framework (#227) Co-authored-by: 6543 <6543@obermui.de> Co-authored-by: John Olheiser Co-authored-by: techknowlogick Reviewed-on: https://gitea.com/gitea/go-sdk/pulls/225 Reviewed-by: Andrew Thornton Reviewed-by: Lunny Xiao Co-authored-by: 6543 <6543@obermui.de> Reviewed-on: https://gitea.com/gitea/go-sdk/pulls/231 Reviewed-by: Lunny Xiao Reviewed-by: John Olheiser --- .drone.yml | 1 + .gitignore | 3 +++ Makefile | 43 ++++++++++++++++++++++++++++++++++++++++++- gitea/issue_test.go | 2 +- 4 files changed, 47 insertions(+), 2 deletions(-) diff --git a/.drone.yml b/.drone.yml index 94f8567..6cb9997 100644 --- a/.drone.yml +++ b/.drone.yml @@ -21,6 +21,7 @@ steps: - echo "INTERNAL_TOKEN = eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJuYmYiOjE1NTg4MzY4ODB9.LoKQyK5TN_0kMJFVHWUW0uDAyoGjDP6Mkup4ps2VJN4" >> /tmp/conf/app.ini - echo "INSTALL_LOCK = true" >> /tmp/conf/app.ini - echo "SECRET_KEY = 2crAW4UANgvLipDS6U5obRcFosjSJHQANll6MNfX7P0G3se3fKcCwwK3szPyGcbo" >> /tmp/conf/app.ini + - echo "PASSWORD_COMPLEXITY = off" >> /tmp/conf/app.ini - echo "[database]" >> /tmp/conf/app.ini - echo "DB_TYPE = sqlite3" >> /tmp/conf/app.ini - echo "[repository]" >> /tmp/conf/app.ini diff --git a/.gitignore b/.gitignore index 42ca3ea..81a2c4d 100644 --- a/.gitignore +++ b/.gitignore @@ -27,3 +27,6 @@ coverage.out # JetBrains .idea + +#integrations +test diff --git a/Makefile b/Makefile index ccc89ac..51876aa 100644 --- a/Makefile +++ b/Makefile @@ -1,8 +1,28 @@ +WORK_DIR := $(shell pwd) + +export GITEA_SDK_TEST_URL ?= http://localhost:3000 +export GITEA_SDK_TEST_USERNAME ?= test01 +export GITEA_SDK_TEST_PASSWORD ?= test01 + .PHONY: all all: clean test build +.PHONY: help +help: + @echo "Make Routines:" + @echo " - \"\" run \"make clean test build\"" + @echo " - build build sdk" + @echo " - clean clean" + @echo " - fmt format the code" + @echo " - lint run golint" + @echo " - vet examines Go source code and reports" + @echo " - test run unit tests (need a running gitea)" + @echo " - test-instance start a gitea instance for test" + + .PHONY: clean clean: + rm -r -f test go clean -i ./... .PHONY: fmt @@ -22,7 +42,28 @@ lint: .PHONY: test test: - cd gitea && go test -cover -coverprofile coverage.out + @if [ -z "$(shell curl --noproxy "*" "${GITEA_SDK_TEST_URL}/api/v1/version" 2> /dev/null)" ]; then \echo "No test-instance detected!"; exit 1; else \ + cd gitea && go test -cover -coverprofile coverage.out; \ + fi + +.PHONY: test-instance +test-instance: + rm -r ${WORK_DIR}/test 2> /dev/null; \ + mkdir -p ${WORK_DIR}/test/conf/ ${WORK_DIR}/test/data/ + wget "https://dl.gitea.io/gitea/master/gitea-master-linux-amd64" -O ${WORK_DIR}/test/gitea-master; \ + chmod +x ${WORK_DIR}/test/gitea-master; \ + echo "[security]" > ${WORK_DIR}/test/conf/app.ini; \ + echo "INTERNAL_TOKEN = eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJuYmYiOjE1NTg4MzY4ODB9.LoKQyK5TN_0kMJFVHWUW0uDAyoGjDP6Mkup4ps2VJN4" >> ${WORK_DIR}/test/conf/app.ini; \ + echo "INSTALL_LOCK = true" >> ${WORK_DIR}/test/conf/app.ini; \ + echo "SECRET_KEY = 2crAW4UANgvLipDS6U5obRcFosjSJHQANll6MNfX7P0G3se3fKcCwwK3szPyGcbo" >> ${WORK_DIR}/test/conf/app.ini; \ + echo "PASSWORD_COMPLEXITY = off" >> ${WORK_DIR}/test/conf/app.ini; \ + echo "[database]" >> ${WORK_DIR}/test/conf/app.ini; \ + echo "DB_TYPE = sqlite3" >> ${WORK_DIR}/test/conf/app.ini; \ + echo "[repository]" >> ${WORK_DIR}/test/conf/app.ini; \ + echo "ROOT = ${WORK_DIR}/test/data/" >> ${WORK_DIR}/test/conf/app.ini; \ + ${WORK_DIR}/test/gitea-master migrate -c ${WORK_DIR}/test/conf/app.ini; \ + ${WORK_DIR}/test/gitea-master admin create-user --username=${GITEA_SDK_TEST_USERNAME} --password=${GITEA_SDK_TEST_PASSWORD} --email=test01@gitea.io --admin=true --must-change-password=false --access-token -c ${WORK_DIR}/test/conf/app.ini; \ + ${WORK_DIR}/test/gitea-master web -c ${WORK_DIR}/test/conf/app.ini .PHONY: bench bench: diff --git a/gitea/issue_test.go b/gitea/issue_test.go index 72607f7..13129ed 100644 --- a/gitea/issue_test.go +++ b/gitea/issue_test.go @@ -91,7 +91,7 @@ func listIssues(t *testing.T, c *Client) { issues, err = c.ListIssues(ListIssueOption{ Labels: []string{"Label2"}, KeyWord: "Done", - State: "", + State: "all", }) assert.NoError(t, err) assert.Len(t, issues, 1)