From 30636ade34bb0ca09cabd7fcfc280e6aeeb4a888 Mon Sep 17 00:00:00 2001 From: 6543 <6543@noreply.gitea.io> Date: Tue, 28 Jan 2020 06:11:26 +0000 Subject: [PATCH] Add TestMyUser (#237) Co-authored-by: 6543 <6543@obermui.de> Reviewed-on: https://gitea.com/gitea/go-sdk/pulls/237 Reviewed-by: lafriks Reviewed-by: Andrew Thornton --- .drone.yml | 2 ++ Makefile | 2 ++ gitea/user_test.go | 26 ++++++++++++++++++++++++++ 3 files changed, 30 insertions(+) create mode 100644 gitea/user_test.go diff --git a/.drone.yml b/.drone.yml index 3212cb2..cf7e444 100644 --- a/.drone.yml +++ b/.drone.yml @@ -26,6 +26,8 @@ steps: - echo "DB_TYPE = sqlite3" >> /tmp/conf/app.ini - echo "[repository]" >> /tmp/conf/app.ini - echo "ROOT = /tmp/data/" >> /tmp/conf/app.ini + - echo "[server]" >> /tmp/conf/app.ini + - echo "ROOT_URL = http://gitea:3000" >> /tmp/conf/app.ini - gitea migrate -c /tmp/conf/app.ini - gitea admin create-user --username=test01 --password=test01 --email=test01@gitea.io --admin=true --must-change-password=false --access-token -c /tmp/conf/app.ini - gitea web -c /tmp/conf/app.ini diff --git a/Makefile b/Makefile index 3caf6e2..a9e9f8b 100644 --- a/Makefile +++ b/Makefile @@ -68,6 +68,8 @@ test-instance: 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; \ + echo "[server]" >> /tmp/conf/app.ini; \ + echo "ROOT_URL = ${GITEA_SDK_TEST_URL}" >> /tmp/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 diff --git a/gitea/user_test.go b/gitea/user_test.go new file mode 100644 index 0000000..bad97e9 --- /dev/null +++ b/gitea/user_test.go @@ -0,0 +1,26 @@ +// Copyright 2020 The Gitea Authors. All rights reserved. +// Use of this source code is governed by a MIT-style +// license that can be found in the LICENSE file. + +package gitea + +import ( + "log" + "testing" + + "github.com/stretchr/testify/assert" +) + +func TestMyUser(t *testing.T) { + log.Println("== TestMyUser ==") + c := newTestClient() + user, err := c.GetMyUserInfo() + assert.NoError(t, err) + + assert.EqualValues(t, 1, user.ID) + assert.EqualValues(t, "test01", user.UserName) + assert.EqualValues(t, "test01@gitea.io", user.Email) + assert.EqualValues(t, "", user.FullName) + assert.EqualValues(t, getGiteaURL()+"/user/avatar/test01/-1", user.AvatarURL) + assert.Equal(t, true, user.IsAdmin) +}