aboutsummaryrefslogtreecommitdiffstats
path: root/commands/bug/bug_test.go
diff options
context:
space:
mode:
authorMichael Muré <batolettre@gmail.com>2023-01-17 20:25:34 +0100
committerMichael Muré <batolettre@gmail.com>2023-01-17 22:04:34 +0100
commitf23a7f07cc9d7e9b9407e0fcb99de6904f1b52a8 (patch)
treeef4b86e5b4ea357f43685f58a9d2f19bac5e8b3a /commands/bug/bug_test.go
parent9fc8dbf4e167ae3d3a5fd602df74645e07d79679 (diff)
downloadgit-bug-f23a7f07cc9d7e9b9407e0fcb99de6904f1b52a8.tar.gz
commands: remove compact style for "bug", as the width adaptive default renderer cover that usage
Diffstat (limited to 'commands/bug/bug_test.go')
-rw-r--r--commands/bug/bug_test.go50
1 files changed, 19 insertions, 31 deletions
diff --git a/commands/bug/bug_test.go b/commands/bug/bug_test.go
index cb6a4373..e6fadd6f 100644
--- a/commands/bug/bug_test.go
+++ b/commands/bug/bug_test.go
@@ -2,7 +2,6 @@ package bugcmd
import (
"encoding/json"
- "fmt"
"testing"
"github.com/stretchr/testify/require"
@@ -61,44 +60,33 @@ $`
format string
exp string
}{
- {"default", "^[0-9a-f]{7}\topen\tthis is a bug title \tJohn Doe \t\n$"},
- {"plain", "^[0-9a-f]{7} \\[open\\] this is a bug title\n$"},
- {"compact", "^[0-9a-f]{7} open this is a bug title John Doe\n$"},
+ {"default", "^[0-9a-f]{7}\topen\tthis is a bug title John Doe \n$"},
+ {"plain", "^[0-9a-f]{7}\topen\tthis is a bug title\n$"},
{"id", "^[0-9a-f]{64}\n$"},
{"org-mode", expOrgMode},
+ {"json", ".*"},
}
for _, testcase := range cases {
- opts := bugOptions{
- sortDirection: "asc",
- sortBy: "creation",
- outputFormat: testcase.format,
- }
-
- name := fmt.Sprintf("with %s format", testcase.format)
-
- t.Run(name, func(t *testing.T) {
+ t.Run(testcase.format, func(t *testing.T) {
env, _ := testenv.NewTestEnvAndBug(t)
+ opts := bugOptions{
+ sortDirection: "asc",
+ sortBy: "creation",
+ outputFormat: testcase.format,
+ }
+
require.NoError(t, runBug(env, opts, []string{}))
- require.Regexp(t, testcase.exp, env.Out.String())
+
+ switch testcase.format {
+ case "json":
+ var bugs []cmdjson.BugExcerpt
+ require.NoError(t, json.Unmarshal(env.Out.Bytes(), &bugs))
+ require.Len(t, bugs, 1)
+ default:
+ require.Regexp(t, testcase.exp, env.Out.String())
+ }
})
}
-
- t.Run("with JSON format", func(t *testing.T) {
- opts := bugOptions{
- sortDirection: "asc",
- sortBy: "creation",
- outputFormat: "json",
- }
-
- env, _ := testenv.NewTestEnvAndBug(t)
-
- require.NoError(t, runBug(env, opts, []string{}))
-
- var bugs []cmdjson.BugExcerpt
- require.NoError(t, json.Unmarshal(env.Out.Bytes(), &bugs))
-
- require.Len(t, bugs, 1)
- })
}