@@ -12,6 +12,36 @@ import (
1212
1313const nonEmptyStr = "any"
1414
15+ func Test_Config_Redacted (t * testing.T ) {
16+ t .Parallel ()
17+
18+ cfg := newValidCfg ()
19+ cfg .Badge .Git .Token = nonEmptyStr
20+ cfg .Badge .CDN .Secret = nonEmptyStr
21+ cfg .Badge .CDN .Key = nonEmptyStr
22+
23+ r := cfg .Redacted ()
24+
25+ // redacted should not be equal to original
26+ assert .NotEqual (t , cfg , r )
27+
28+ // original should not change
29+ assert .Equal (t , nonEmptyStr , cfg .Badge .Git .Token )
30+ assert .Equal (t , nonEmptyStr , cfg .Badge .CDN .Secret )
31+ assert .Equal (t , nonEmptyStr , cfg .Badge .CDN .Key )
32+
33+ // redacted should have hidden values
34+ assert .Equal (t , HiddenValue , r .Badge .Git .Token )
35+ assert .Equal (t , HiddenValue , r .Badge .CDN .Secret )
36+ assert .Equal (t , nonEmptyStr + HiddenValue , r .Badge .CDN .Key )
37+
38+ // redacted config of empty field should not do anything
39+ r = Config {}.Redacted ()
40+ assert .Empty (t , r .Badge .Git .Token )
41+ assert .Empty (t , r .Badge .CDN .Secret )
42+ assert .Empty (t , r .Badge .CDN .Key )
43+ }
44+
1545func Test_Config_Validate (t * testing.T ) {
1646 t .Parallel ()
1747
0 commit comments