8fab37e740
- Enforce [gofumpt](https://github.com/mvdan/gofumpt) to enforce a more idiomatic go style. - Enforce golangci-lint a bunch of linters! Which were able to detect a few issues in the current codebase and have been fixed by this PR. - Updated the Makefile to use `go install ....` instead of the old deprecated way of `go get` Reviewed-on: https://gitea.com/gitea/go-sdk/pulls/587 Reviewed-by: John Olheiser <john.olheiser@gmail.com> Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com> Co-authored-by: Gusted <williamzijl7@hotmail.com> Co-committed-by: Gusted <williamzijl7@hotmail.com>
52 lines
1.3 KiB
Go
52 lines
1.3 KiB
Go
// 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 TestRepoWatch(t *testing.T) {
|
|
log.Printf("== TestRepoWatch ==")
|
|
c := newTestClient()
|
|
rawVersion, _, err := c.ServerVersion()
|
|
assert.NoError(t, err)
|
|
assert.True(t, true, rawVersion != "")
|
|
|
|
repo1, _ := createTestRepo(t, "TestRepoWatch_1", c)
|
|
repo2, _ := createTestRepo(t, "TestRepoWatch_2", c)
|
|
assert.NotEqual(t, repo1, repo2)
|
|
|
|
// GetWatchedRepos
|
|
wl, _, err := c.GetWatchedRepos("test01")
|
|
assert.NoError(t, err)
|
|
assert.NotNil(t, wl)
|
|
maxcount := len(wl)
|
|
|
|
// GetMyWatchedRepos
|
|
wl, _, err = c.GetMyWatchedRepos()
|
|
assert.NoError(t, err)
|
|
assert.Len(t, wl, maxcount)
|
|
|
|
// CheckRepoWatch
|
|
isWatching, _, err := c.CheckRepoWatch(repo1.Owner.UserName, repo1.Name)
|
|
assert.NoError(t, err)
|
|
assert.True(t, isWatching)
|
|
|
|
// UnWatchRepo
|
|
_, err = c.UnWatchRepo(repo1.Owner.UserName, repo1.Name)
|
|
assert.NoError(t, err)
|
|
isWatching, _, _ = c.CheckRepoWatch(repo1.Owner.UserName, repo1.Name)
|
|
assert.False(t, isWatching)
|
|
|
|
// WatchRepo
|
|
_, err = c.WatchRepo(repo1.Owner.UserName, repo1.Name)
|
|
assert.NoError(t, err)
|
|
isWatching, _, _ = c.CheckRepoWatch(repo1.Owner.UserName, repo1.Name)
|
|
assert.True(t, isWatching)
|
|
}
|