-
Notifications
You must be signed in to change notification settings - Fork 0
/
redact_test.go
49 lines (37 loc) · 846 Bytes
/
redact_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package launch_test
import (
"encoding/json"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
. "github.com/clarktrimble/launch"
)
var _ = Describe("Redact", func() {
var (
data []byte
err error
redact Redact
)
Describe("marshalling a redact string", func() {
JustBeforeEach(func() {
data, err = json.Marshal(redact)
})
When("value is set", func() {
BeforeEach(func() {
redact = Redact("password_or_token")
})
It("shows redacted", func() {
Expect(err).ToNot(HaveOccurred())
Expect(data).To(Equal([]byte(`"--redacted--"`)))
})
})
When("value is not set", func() {
BeforeEach(func() {
redact = Redact("")
})
It("indicates the value is not set", func() {
Expect(err).ToNot(HaveOccurred())
Expect(data).To(Equal([]byte(`"--unset--"`)))
})
})
})
})