forgejo-sdk/gitea/user_settings_test.go
6543 79f379313c Add user settings get & update functions (#531)
close #529

Reviewed-on: https://gitea.com/gitea/go-sdk/pulls/531
Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com>
Reviewed-by: Norwin <noerw@noreply.gitea.io>
Co-authored-by: 6543 <6543@obermui.de>
Co-committed-by: 6543 <6543@obermui.de>
2021-07-03 23:50:45 +08:00

48 lines
1.1 KiB
Go

// Copyright 2021 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 TestUserSettings(t *testing.T) {
log.Println("== TestUserSettings ==")
c := newTestClient()
userConf, _, err := c.GetUserSettings()
assert.NoError(t, err)
assert.NotNil(t, userConf)
assert.EqualValues(t, UserSettings{
Theme: "gitea",
HideEmail: false,
HideActivity: false,
}, *userConf)
userConf, _, err = c.UpdateUserSettings(UserSettingsOptions{
FullName: OptionalString("Admin User on Test"),
Language: OptionalString("de_de"),
HideEmail: OptionalBool(true),
})
assert.NoError(t, err)
assert.NotNil(t, userConf)
assert.EqualValues(t, UserSettings{
FullName: "Admin User on Test",
Theme: "gitea",
Language: "de_de",
HideEmail: true,
HideActivity: false,
}, *userConf)
_, _, err = c.UpdateUserSettings(UserSettingsOptions{
FullName: OptionalString(""),
Language: OptionalString(""),
HideEmail: OptionalBool(false),
})
assert.NoError(t, err)
}