mirror of
https://github.com/juanfont/headscale.git
synced 2026-10-31 02:34:07 +09:00
hscontrol: keep golden file names valid in Go module zips
A '>' in one name stopped go get from fetching headscale.
This commit is contained in:
1 parent
0dd9079d0b
commit
46e374aa78
2 files changed
+10
-1
No files matched your search
@@ -13,6 +13,7 @@ import (
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
"unicode"
|
||||
|
||||
apiv1 "github.com/juanfont/headscale/hscontrol/api/v1"
|
||||
"github.com/stretchr/testify/assert"
|
||||
@@ -142,7 +143,15 @@ type goldenRecord struct {
|
||||
func goldenPath(t *testing.T) string {
|
||||
t.Helper()
|
||||
|
||||
name := strings.NewReplacer("/", "_", " ", "_").Replace(t.Name())
|
||||
// Go module zips refuse names with characters such as '>', and one
|
||||
// such file stops go get from fetching headscale.
|
||||
name := strings.Map(func(r rune) rune {
|
||||
if r == '-' || r == '.' || unicode.IsLetter(r) || unicode.IsDigit(r) {
|
||||
return r
|
||||
}
|
||||
|
||||
return '_'
|
||||
}, t.Name())
|
||||
|
||||
return filepath.Join(goldenDir, name+".json")
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user