test: pin today's output with compatibility goldens (#649)

Phase 0, part 2: freeze the output files, keys.json, and archives today's
code writes, so every later phase can prove it changes nothing.
This commit is contained in:
Roger authored and GitHub committed 2026-10-26 16:22:58 +08:00
1 parent f4c05f861f
commit fb86bd368e
22 files changed
+3607 -16

No files matched your search

+1 -16
View File
@@ -1,9 +1,6 @@
package main
import (
"flag"
"os"
"path/filepath"
"sort"
"strconv"
"strings"
@@ -11,22 +8,10 @@ import (
"github.com/spf13/cobra"
"github.com/spf13/pflag"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
var update = flag.Bool("update", false, "rewrite testdata/flags.golden from the current command tree")
func TestFlagSurface(t *testing.T) {
golden := filepath.Join("testdata", "flags.golden")
got := flagSurface(rootCmd())
if *update {
require.NoError(t, os.MkdirAll(filepath.Dir(golden), 0o755))
require.NoError(t, os.WriteFile(golden, []byte(got), 0o644))
}
want, err := os.ReadFile(golden)
require.NoError(t, err)
assert.Equal(t, string(want), got, "regenerate with: go test ./cmd/hack-browser-data -run TestFlagSurface -update")
assertGolden(t, "flags.golden", flagSurface(rootCmd()))
}
func flagSurface(root *cobra.Command) string {