aboutsummaryrefslogtreecommitdiffstats
path: root/commands/execenv/env_testing.go
diff options
context:
space:
mode:
authorMichael Muré <batolettre@gmail.com>2022-12-29 12:49:12 +0100
committerMichael Muré <batolettre@gmail.com>2022-12-29 12:53:06 +0100
commit5844dd0a6a08f496e6018c0bad0b38d82a8846fc (patch)
treee0a22258e29c12bec617b18298bea6bb377aede6 /commands/execenv/env_testing.go
parent211a038c6057c5cfdcbf4c7d4cc8b4e93d8dc8db (diff)
downloadgit-bug-5844dd0a6a08f496e6018c0bad0b38d82a8846fc.tar.gz
commands: share JSON creation
Diffstat (limited to 'commands/execenv/env_testing.go')
-rw-r--r--commands/execenv/env_testing.go10
1 files changed, 10 insertions, 0 deletions
diff --git a/commands/execenv/env_testing.go b/commands/execenv/env_testing.go
index 5761b410..34eafc9c 100644
--- a/commands/execenv/env_testing.go
+++ b/commands/execenv/env_testing.go
@@ -2,6 +2,7 @@ package execenv
import (
"bytes"
+ "encoding/json"
"fmt"
"testing"
@@ -27,6 +28,15 @@ func (te *TestOut) Println(a ...interface{}) {
_, _ = fmt.Fprintln(te.Buffer, a...)
}
+func (te *TestOut) PrintJSON(v interface{}) error {
+ raw, err := json.MarshalIndent(v, "", " ")
+ if err != nil {
+ return err
+ }
+ te.Println(string(raw))
+ return nil
+}
+
func NewTestEnv(t *testing.T) *Env {
t.Helper()