Skip to content
This repository was archived by the owner on Feb 16, 2023. It is now read-only.

Commit 131816d

Browse files
committed
Adjusted tests with coloring
1 parent 519e5b2 commit 131816d

1 file changed

Lines changed: 11 additions & 9 deletions

File tree

internals/secrethub/tree_test.go

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package secrethub
22

33
import (
44
"bytes"
5+
"github.com/fatih/color"
56
"testing"
67

78
"github.com/secrethub/secrethub-cli/internals/cli/ui"
@@ -138,13 +139,14 @@ func TestSimpleTree(t *testing.T) {
138139
}
139140

140141
func TestTreeColoring(t *testing.T) {
142+
color.NoColor = false
141143
uuid0, _ := uuid.FromString("0")
142144
uuid1, _ := uuid.FromString("1")
143145
uuid2, _ := uuid.FromString("2")
144146
tree := &api.Tree{
145147
RootDir: &api.Dir{
146148
Name: "test/repo",
147-
Status: "flagged",
149+
Status: api.StatusFlagged,
148150
DirID: uuid0,
149151
SubDirs: []*api.Dir{
150152
{
@@ -156,11 +158,11 @@ func TestTreeColoring(t *testing.T) {
156158
Name: "secretFolder",
157159
DirID: uuid2,
158160
ParentID: &uuid0,
159-
Status: "flagged",
161+
Status: api.StatusFlagged,
160162
Secrets: []*api.Secret{
161163
{
162164
Name: "found you",
163-
Status: "flagged",
165+
Status: api.StatusFlagged,
164166
},
165167
},
166168
},
@@ -203,10 +205,10 @@ func TestTreeColoring(t *testing.T) {
203205
return &secrethub.Client{}, nil
204206
},
205207
},
206-
expectedOutput: "test/repo/\n" +
208+
expectedOutput: red.Sprint("test/repo/") + "\n" +
207209
"├── happy/\n" +
208-
"├── secretFolder/\n" +
209-
"│ └── found you\n" +
210+
"├── " + red.Sprint("secretFolder/") + "\n" +
211+
"│ └── " + red.Sprint("found you") + "\n" +
210212
"└── mySecret\n\n" +
211213
"2 directories, 2 secrets\n",
212214
},
@@ -218,10 +220,10 @@ func TestTreeColoring(t *testing.T) {
218220
return &secrethub.Client{}, nil
219221
},
220222
},
221-
expectedOutput: "test/repo/\n" +
223+
expectedOutput: red.Sprint("test/repo/") + "\n" +
222224
"├── test/repo/happy/\n" +
223-
"├── test/repo/secretFolder/\n" +
224-
"│ └── test/repo/secretFolder/found you\n" +
225+
"├── " + red.Sprint("test/repo/secretFolder/") + "\n" +
226+
"│ └── " + red.Sprint("test/repo/secretFolder/found you") + "\n" +
225227
"└── test/repo/mySecret\n\n" +
226228
"2 directories, 2 secrets\n",
227229
},

0 commit comments

Comments
 (0)