// 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 FuzzRoundTripURL(f *testing.F) { f.Fuzz(func(t *testing.T, url string) { t.Logf("url = %q", url) ns := gitcache.URL2NS(url) t.Logf("ns = %q", ns) assert.Equal(t, gitcache.NormalizeURL(url), gitcache.NS2URL(ns)) }) } func FuzzURL2NS(f *testing.F) { f.Fuzz(func(t *testing.T, url string) { if !gitcache.ValidateURL(url) { return } t.Logf("url = %q", url) ns := gitcache.URL2NS(url) t.Logf("ns = %q", ns) assert.False(t, strings.Contains(ns, "/")) assert.NoError(t, exec.Command("git", "check-ref-format", "refs/"+ns).Run()) }) }