aboutsummaryrefslogtreecommitdiffstats
path: root/modules/repository/fork_test.go
blob: f8c76d942d1888464a5c3d0ca364ff8786851d87 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
// Copyright 2024 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT

package repository

import (
	"testing"

	"code.gitea.io/gitea/modules/setting"
	"code.gitea.io/gitea/modules/test"

	"github.com/stretchr/testify/assert"
)

func TestCanUserForkBetweenOwners(t *testing.T) {
	defer test.MockVariableValue(&setting.Repository.AllowForkIntoSameOwner)

	setting.Repository.AllowForkIntoSameOwner = true
	assert.True(t, CanUserForkBetweenOwners(1, 1))
	assert.True(t, CanUserForkBetweenOwners(1, 2))

	setting.Repository.AllowForkIntoSameOwner = false
	assert.False(t, CanUserForkBetweenOwners(1, 1))
	assert.True(t, CanUserForkBetweenOwners(1, 2))
}