-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathhelpers_test.go
43 lines (29 loc) · 1.08 KB
/
helpers_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
package githosts
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestMaskSecretsReplacesSecretsWithAsterisks(t *testing.T) {
content := "Hello, my secret is secret123"
secrets := []string{"secret123"}
maskedContent := maskSecrets(content, secrets)
assert.Equal(t, "Hello, my secret is *********", maskedContent)
}
func TestMaskSecretsHandlesMultipleSecrets(t *testing.T) {
content := "Hello, my secrets are secret123 and secret456"
secrets := []string{"secret123", "secret456"}
maskedContent := maskSecrets(content, secrets)
assert.Equal(t, "Hello, my secrets are ********* and *********", maskedContent)
}
func TestMaskSecretsReturnsOriginalContentWhenNoSecrets(t *testing.T) {
content := "Hello, I have no secrets"
secrets := []string{}
maskedContent := maskSecrets(content, secrets)
assert.Equal(t, content, maskedContent)
}
func TestMaskSecretsDoesNotAlterContentWithoutSecrets(t *testing.T) {
content := "Hello, my secret is not here"
secrets := []string{"secret123"}
maskedContent := maskSecrets(content, secrets)
assert.Equal(t, content, maskedContent)
}