mirror of
https://github.com/slackhq/nebula.git
synced 2026-11-15 16:16:52 +01:00
Extract the ssh debug commands into a transport neutral commands package (#1958)
Migrate commands from ssh into a transport neutral package - add golden tests validating that output remains unchanged - move commands to commands.go Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
1 parent
cda3710d5a
commit
b426843f88
21 files changed
+2038
-978
No files matched your search
@@ -0,0 +1,29 @@
|
||||
package test
|
||||
|
||||
import (
|
||||
"flag"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
// Update is the -update flag: Golden rewrites its file instead of comparing against it.
|
||||
var Update = flag.Bool("update", false, "rewrite golden files instead of comparing against them")
|
||||
|
||||
// Golden compares got with the file at path, or rewrites the file when -update is set.
|
||||
func Golden(t *testing.T, path, got string) {
|
||||
t.Helper()
|
||||
|
||||
if *Update {
|
||||
require.NoError(t, os.MkdirAll(filepath.Dir(path), 0755))
|
||||
require.NoError(t, os.WriteFile(path, []byte(got), 0644))
|
||||
return
|
||||
}
|
||||
|
||||
want, err := os.ReadFile(path)
|
||||
require.NoError(t, err, "missing golden file, run with -update")
|
||||
assert.Equal(t, string(want), got)
|
||||
}
|
||||
Reference in new issue
Block a user