eclipse/lib/gitcache/gitrevisions_test.go

28 lines
574 B
Go

// Copyright (C) 2024 Umorpha Systems
// SPDX-License-Identifier: AGPL-3.0-or-later
package gitcache_test
import (
"os/exec"
"strings"
"testing"
"github.com/stretchr/testify/assert"
"git.mothstuff.lol/lukeshu/eclipse/lib/gitcache"
)
func FuzzValidateRef(f *testing.F) {
f.Add("refs/heads/main")
f.Add("refs/heads/*")
f.Fuzz(func(t *testing.T, ref string) {
if !strings.HasPrefix(ref, "refs/") {
return
}
goOK := gitcache.ValidateRef(ref, false)
gitOK := exec.Command("git", "check-ref-format", ref).Run() == nil
assert.Equal(t, gitOK, goOK)
})
}