From 46e374aa78ac7ac2e580027ce87188dc7a33ae18 Mon Sep 17 00:00:00 2001 From: Kristoffer Dalby Date: Thu, 29 Oct 2026 07:34:41 +0000 Subject: [PATCH] hscontrol: keep golden file names valid in Go module zips A '>' in one name stopped go get from fetching headscale. --- hscontrol/apiv1_harness_test.go | 11 ++++++++++- ...h_prefix_with_id_query_is_both_-__400_parity.json} | 0 2 files changed, 10 insertions(+), 1 deletion(-) rename hscontrol/testdata/apiv1_golden/{TestAPIV1ApiKeyDelete_path_prefix_with_id_query_is_both_->_400_parity.json => TestAPIV1ApiKeyDelete_path_prefix_with_id_query_is_both_-__400_parity.json} (100%) diff --git a/hscontrol/apiv1_harness_test.go b/hscontrol/apiv1_harness_test.go index 256ccf89b..7108044ea 100644 --- a/hscontrol/apiv1_harness_test.go +++ b/hscontrol/apiv1_harness_test.go @@ -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") } diff --git a/hscontrol/testdata/apiv1_golden/TestAPIV1ApiKeyDelete_path_prefix_with_id_query_is_both_->_400_parity.json b/hscontrol/testdata/apiv1_golden/TestAPIV1ApiKeyDelete_path_prefix_with_id_query_is_both_-__400_parity.json similarity index 100% rename from hscontrol/testdata/apiv1_golden/TestAPIV1ApiKeyDelete_path_prefix_with_id_query_is_both_->_400_parity.json rename to hscontrol/testdata/apiv1_golden/TestAPIV1ApiKeyDelete_path_prefix_with_id_query_is_both_-__400_parity.json