forked from go-gitea/gitea
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'src/release/v1.17' into release/v1.17
* src/release/v1.17: (26 commits) Fix reaction of issues (go-gitea#21185) (go-gitea#21196) Fix CSV diff for added/deleted files (go-gitea#21189) (go-gitea#21193) Fix pagination limit parameter problem (go-gitea#21111) Add MD5 back to template helper functions to avoid breaking (go-gitea#21102) Add changelog for v1.17.2 (go-gitea#21089) Fix sub folder in repository missing add file dropdown (go-gitea#21069) (go-gitea#21083) Fix hard-coded timeout and error panic in API archive download endpoint (go-gitea#20925) (go-gitea#21051) Fix delete user missed some comments (go-gitea#21067) (go-gitea#21068) Delete unreferenced packages when deleting a package version (go-gitea#20977) (go-gitea#21060) Redirect if user does not exist on admin pages (go-gitea#20981) (go-gitea#21059) Set uploadpack.allowFilter etc on gitea serv to enable partial clones with ssh (go-gitea#20902) (go-gitea#21058) Fix 500 on time in timeline API (go-gitea#21052) (go-gitea#21057) Fill the specified ref in webhook test payload (go-gitea#20961) (go-gitea#21055) Add another index for Action table on postgres (go-gitea#21033) (go-gitea#21054) fix broken insecureskipverify handling in rediss connection uris (go-gitea#20967) (go-gitea#21053) Add more checks in migration code (go-gitea#21011) (go-gitea#21050) Add Dev, Peer and Optional dependencies to npm PackageMetadataVersion (go-gitea#21017) (go-gitea#21044) Improve arc-green code theme (go-gitea#21039) (go-gitea#21042) Add down key check has tribute container (go-gitea#21016) (go-gitea#21038) Do not add links to Posters or Assignees with ID < 0 (go-gitea#20577) (go-gitea#21037) ...
- Loading branch information
Showing
75 changed files
with
1,329 additions
and
686 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
// Copyright 2022 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 packages_test | ||
|
||
import ( | ||
"path/filepath" | ||
"testing" | ||
|
||
"code.gitea.io/gitea/models/db" | ||
packages_model "code.gitea.io/gitea/models/packages" | ||
"code.gitea.io/gitea/models/unittest" | ||
user_model "code.gitea.io/gitea/models/user" | ||
|
||
_ "code.gitea.io/gitea/models" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestMain(m *testing.M) { | ||
unittest.MainTest(m, &unittest.TestOptions{ | ||
GiteaRootPath: filepath.Join("..", ".."), | ||
}) | ||
} | ||
|
||
func TestHasOwnerPackages(t *testing.T) { | ||
assert.NoError(t, unittest.PrepareTestDatabase()) | ||
|
||
owner := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 1}).(*user_model.User) | ||
|
||
p, err := packages_model.TryInsertPackage(db.DefaultContext, &packages_model.Package{ | ||
OwnerID: owner.ID, | ||
LowerName: "package", | ||
}) | ||
assert.NotNil(t, p) | ||
assert.NoError(t, err) | ||
|
||
// A package without package versions gets automatically cleaned up and should return false | ||
has, err := packages_model.HasOwnerPackages(db.DefaultContext, owner.ID) | ||
assert.False(t, has) | ||
assert.NoError(t, err) | ||
|
||
pv, err := packages_model.GetOrInsertVersion(db.DefaultContext, &packages_model.PackageVersion{ | ||
PackageID: p.ID, | ||
LowerVersion: "internal", | ||
IsInternal: true, | ||
}) | ||
assert.NotNil(t, pv) | ||
assert.NoError(t, err) | ||
|
||
// A package with an internal package version gets automaticaly cleaned up and should return false | ||
has, err = packages_model.HasOwnerPackages(db.DefaultContext, owner.ID) | ||
assert.False(t, has) | ||
assert.NoError(t, err) | ||
|
||
pv, err = packages_model.GetOrInsertVersion(db.DefaultContext, &packages_model.PackageVersion{ | ||
PackageID: p.ID, | ||
LowerVersion: "normal", | ||
IsInternal: false, | ||
}) | ||
assert.NotNil(t, pv) | ||
assert.NoError(t, err) | ||
|
||
// A package with a normal package version should return true | ||
has, err = packages_model.HasOwnerPackages(db.DefaultContext, owner.ID) | ||
assert.True(t, has) | ||
assert.NoError(t, err) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.