mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-11-23 19:11:58 +01:00
Merge pull request 'Fixes #2452 - Skipping SHA256 tests if unsupported' (#2456) from lhinderberger/forgejo:2452-skip-sha256-if-unsupported into forgejo
Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/2456 Reviewed-by: Gusted <gusted@noreply.codeberg.org> Reviewed-by: Earl Warren <earl-warren@noreply.codeberg.org>
This commit is contained in:
commit
b7ea2ea463
3 changed files with 31 additions and 0 deletions
|
@ -11,6 +11,8 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestReadingBlameOutputSha256(t *testing.T) {
|
func TestReadingBlameOutputSha256(t *testing.T) {
|
||||||
|
skipIfSHA256NotSupported(t)
|
||||||
|
|
||||||
ctx, cancel := context.WithCancel(context.Background())
|
ctx, cancel := context.WithCancel(context.Background())
|
||||||
defer cancel()
|
defer cancel()
|
||||||
|
|
||||||
|
|
|
@ -14,6 +14,8 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestCommitsCountSha256(t *testing.T) {
|
func TestCommitsCountSha256(t *testing.T) {
|
||||||
|
skipIfSHA256NotSupported(t)
|
||||||
|
|
||||||
bareRepo1Path := filepath.Join(testReposDir, "repo1_bare_sha256")
|
bareRepo1Path := filepath.Join(testReposDir, "repo1_bare_sha256")
|
||||||
|
|
||||||
commitsCount, err := CommitsCount(DefaultContext,
|
commitsCount, err := CommitsCount(DefaultContext,
|
||||||
|
@ -27,6 +29,8 @@ func TestCommitsCountSha256(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestCommitsCountWithoutBaseSha256(t *testing.T) {
|
func TestCommitsCountWithoutBaseSha256(t *testing.T) {
|
||||||
|
skipIfSHA256NotSupported(t)
|
||||||
|
|
||||||
bareRepo1Path := filepath.Join(testReposDir, "repo1_bare_sha256")
|
bareRepo1Path := filepath.Join(testReposDir, "repo1_bare_sha256")
|
||||||
|
|
||||||
commitsCount, err := CommitsCount(DefaultContext,
|
commitsCount, err := CommitsCount(DefaultContext,
|
||||||
|
@ -41,6 +45,8 @@ func TestCommitsCountWithoutBaseSha256(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestGetFullCommitIDSha256(t *testing.T) {
|
func TestGetFullCommitIDSha256(t *testing.T) {
|
||||||
|
skipIfSHA256NotSupported(t)
|
||||||
|
|
||||||
bareRepo1Path := filepath.Join(testReposDir, "repo1_bare_sha256")
|
bareRepo1Path := filepath.Join(testReposDir, "repo1_bare_sha256")
|
||||||
|
|
||||||
id, err := GetFullCommitID(DefaultContext, bareRepo1Path, "f004f4")
|
id, err := GetFullCommitID(DefaultContext, bareRepo1Path, "f004f4")
|
||||||
|
@ -49,6 +55,8 @@ func TestGetFullCommitIDSha256(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestGetFullCommitIDErrorSha256(t *testing.T) {
|
func TestGetFullCommitIDErrorSha256(t *testing.T) {
|
||||||
|
skipIfSHA256NotSupported(t)
|
||||||
|
|
||||||
bareRepo1Path := filepath.Join(testReposDir, "repo1_bare_sha256")
|
bareRepo1Path := filepath.Join(testReposDir, "repo1_bare_sha256")
|
||||||
|
|
||||||
id, err := GetFullCommitID(DefaultContext, bareRepo1Path, "unknown")
|
id, err := GetFullCommitID(DefaultContext, bareRepo1Path, "unknown")
|
||||||
|
@ -59,6 +67,8 @@ func TestGetFullCommitIDErrorSha256(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestCommitFromReaderSha256(t *testing.T) {
|
func TestCommitFromReaderSha256(t *testing.T) {
|
||||||
|
skipIfSHA256NotSupported(t)
|
||||||
|
|
||||||
commitString := `9433b2a62b964c17a4485ae180f45f595d3e69d31b786087775e28c6b6399df0 commit 1114
|
commitString := `9433b2a62b964c17a4485ae180f45f595d3e69d31b786087775e28c6b6399df0 commit 1114
|
||||||
tree e7f9e96dd79c09b078cac8b303a7d3b9d65ff9b734e86060a4d20409fd379f9e
|
tree e7f9e96dd79c09b078cac8b303a7d3b9d65ff9b734e86060a4d20409fd379f9e
|
||||||
parent 26e9ccc29fad747e9c5d9f4c9ddeb7eff61cc45ef6a8dc258cbeb181afc055e8
|
parent 26e9ccc29fad747e9c5d9f4c9ddeb7eff61cc45ef6a8dc258cbeb181afc055e8
|
||||||
|
@ -131,6 +141,8 @@ signed commit`, commitFromReader.Signature.Payload)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestHasPreviousCommitSha256(t *testing.T) {
|
func TestHasPreviousCommitSha256(t *testing.T) {
|
||||||
|
skipIfSHA256NotSupported(t)
|
||||||
|
|
||||||
bareRepo1Path := filepath.Join(testReposDir, "repo1_bare_sha256")
|
bareRepo1Path := filepath.Join(testReposDir, "repo1_bare_sha256")
|
||||||
|
|
||||||
repo, err := openRepositoryWithDefaultContext(bareRepo1Path)
|
repo, err := openRepositoryWithDefaultContext(bareRepo1Path)
|
||||||
|
@ -159,6 +171,8 @@ func TestHasPreviousCommitSha256(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestGetCommitFileStatusMergesSha256(t *testing.T) {
|
func TestGetCommitFileStatusMergesSha256(t *testing.T) {
|
||||||
|
skipIfSHA256NotSupported(t)
|
||||||
|
|
||||||
bareRepo1Path := filepath.Join(testReposDir, "repo6_merge_sha256")
|
bareRepo1Path := filepath.Join(testReposDir, "repo6_merge_sha256")
|
||||||
|
|
||||||
commitFileStatus, err := GetCommitFileStatus(DefaultContext, bareRepo1Path, "d2e5609f630dd8db500f5298d05d16def282412e3e66ed68cc7d0833b29129a1")
|
commitFileStatus, err := GetCommitFileStatus(DefaultContext, bareRepo1Path, "d2e5609f630dd8db500f5298d05d16def282412e3e66ed68cc7d0833b29129a1")
|
||||||
|
|
15
modules/git/utils_test.go
Normal file
15
modules/git/utils_test.go
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
// Copyright 2024 The Forgejo Authors. All rights reserved.
|
||||||
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
|
package git
|
||||||
|
|
||||||
|
import "testing"
|
||||||
|
|
||||||
|
// This file contains utility functions that are used across multiple tests,
|
||||||
|
// but not in production code.
|
||||||
|
|
||||||
|
func skipIfSHA256NotSupported(t *testing.T) {
|
||||||
|
if isGogit || CheckGitVersionAtLeast("2.42") != nil {
|
||||||
|
t.Skip("skipping because installed Git version doesn't support SHA256")
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue