2020-01-12 17:41:17 +05:30
|
|
|
// Copyright 2019 The Gitea Authors. All rights reserved.
|
2022-11-27 23:50:29 +05:30
|
|
|
// SPDX-License-Identifier: MIT
|
2020-01-12 17:41:17 +05:30
|
|
|
|
|
|
|
package repository
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
2022-08-25 08:01:57 +05:30
|
|
|
activities_model "code.gitea.io/gitea/models/activities"
|
2021-11-18 23:12:27 +05:30
|
|
|
"code.gitea.io/gitea/models/db"
|
2022-06-06 13:31:49 +05:30
|
|
|
repo_model "code.gitea.io/gitea/models/repo"
|
2021-11-12 20:06:47 +05:30
|
|
|
"code.gitea.io/gitea/models/unittest"
|
2020-01-12 17:41:17 +05:30
|
|
|
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
)
|
|
|
|
|
2022-06-06 13:31:49 +05:30
|
|
|
func TestUpdateRepositoryVisibilityChanged(t *testing.T) {
|
|
|
|
assert.NoError(t, unittest.PrepareTestDatabase())
|
|
|
|
|
|
|
|
// Get sample repo and change visibility
|
2022-12-03 08:18:26 +05:30
|
|
|
repo, err := repo_model.GetRepositoryByID(db.DefaultContext, 9)
|
2022-06-06 13:31:49 +05:30
|
|
|
assert.NoError(t, err)
|
|
|
|
repo.IsPrivate = true
|
|
|
|
|
|
|
|
// Update it
|
|
|
|
err = UpdateRepository(db.DefaultContext, repo, true)
|
|
|
|
assert.NoError(t, err)
|
|
|
|
|
|
|
|
// Check visibility of action has become private
|
2022-08-25 08:01:57 +05:30
|
|
|
act := activities_model.Action{}
|
2022-06-06 13:31:49 +05:30
|
|
|
_, err = db.GetEngine(db.DefaultContext).ID(3).Get(&act)
|
|
|
|
|
|
|
|
assert.NoError(t, err)
|
|
|
|
assert.True(t, act.IsPrivate)
|
|
|
|
}
|
2023-01-14 00:24:02 +05:30
|
|
|
|
|
|
|
func TestGetDirectorySize(t *testing.T) {
|
|
|
|
assert.NoError(t, unittest.PrepareTestDatabase())
|
|
|
|
repo, err := repo_model.GetRepositoryByID(db.DefaultContext, 1)
|
|
|
|
assert.NoError(t, err)
|
|
|
|
|
|
|
|
size, err := getDirectorySize(repo.RepoPath())
|
|
|
|
assert.NoError(t, err)
|
|
|
|
assert.EqualValues(t, size, repo.Size)
|
|
|
|
}
|