0
Fork 0
mirror of https://codeberg.org/forgejo/forgejo.git synced 2024-12-22 23:33:15 -05:00

Fixes #2452 - Skipping SHA256 tests if unsupported

The test suite was broken e.g. on Debian 12 due to requiring a very
recent version of Git installed on the system. This commit skips SHA256
tests in the git module, if a Git version older than 2.42 or gogit is used.
This commit is contained in:
Lucas Hinderberger 2024-02-24 00:06:53 +01:00
parent b8563acedb
commit a4b0c0edc5
3 changed files with 32 additions and 0 deletions

View file

@ -11,6 +11,8 @@ import (
)
func TestReadingBlameOutputSha256(t *testing.T) {
skipIfSHA256NotSupported(t)
ctx, cancel := context.WithCancel(context.Background())
defer cancel()

View file

@ -14,6 +14,8 @@ import (
)
func TestCommitsCountSha256(t *testing.T) {
skipIfSHA256NotSupported(t)
bareRepo1Path := filepath.Join(testReposDir, "repo1_bare_sha256")
commitsCount, err := CommitsCount(DefaultContext,
@ -27,6 +29,8 @@ func TestCommitsCountSha256(t *testing.T) {
}
func TestCommitsCountWithoutBaseSha256(t *testing.T) {
skipIfSHA256NotSupported(t)
bareRepo1Path := filepath.Join(testReposDir, "repo1_bare_sha256")
commitsCount, err := CommitsCount(DefaultContext,
@ -41,6 +45,8 @@ func TestCommitsCountWithoutBaseSha256(t *testing.T) {
}
func TestGetFullCommitIDSha256(t *testing.T) {
skipIfSHA256NotSupported(t)
bareRepo1Path := filepath.Join(testReposDir, "repo1_bare_sha256")
id, err := GetFullCommitID(DefaultContext, bareRepo1Path, "f004f4")
@ -49,6 +55,8 @@ func TestGetFullCommitIDSha256(t *testing.T) {
}
func TestGetFullCommitIDErrorSha256(t *testing.T) {
skipIfSHA256NotSupported(t)
bareRepo1Path := filepath.Join(testReposDir, "repo1_bare_sha256")
id, err := GetFullCommitID(DefaultContext, bareRepo1Path, "unknown")
@ -59,6 +67,8 @@ func TestGetFullCommitIDErrorSha256(t *testing.T) {
}
func TestCommitFromReaderSha256(t *testing.T) {
skipIfSHA256NotSupported(t)
commitString := `9433b2a62b964c17a4485ae180f45f595d3e69d31b786087775e28c6b6399df0 commit 1114
tree e7f9e96dd79c09b078cac8b303a7d3b9d65ff9b734e86060a4d20409fd379f9e
parent 26e9ccc29fad747e9c5d9f4c9ddeb7eff61cc45ef6a8dc258cbeb181afc055e8
@ -131,6 +141,8 @@ signed commit`, commitFromReader.Signature.Payload)
}
func TestHasPreviousCommitSha256(t *testing.T) {
skipIfSHA256NotSupported(t)
bareRepo1Path := filepath.Join(testReposDir, "repo1_bare_sha256")
repo, err := openRepositoryWithDefaultContext(bareRepo1Path)
@ -159,6 +171,8 @@ func TestHasPreviousCommitSha256(t *testing.T) {
}
func TestGetCommitFileStatusMergesSha256(t *testing.T) {
skipIfSHA256NotSupported(t)
bareRepo1Path := filepath.Join(testReposDir, "repo6_merge_sha256")
commitFileStatus, err := GetCommitFileStatus(DefaultContext, bareRepo1Path, "d2e5609f630dd8db500f5298d05d16def282412e3e66ed68cc7d0833b29129a1")

16
modules/git/utils_test.go Normal file
View file

@ -0,0 +1,16 @@
// 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")
}
}