-
Notifications
You must be signed in to change notification settings - Fork 4.5k
/
servicebus_test.go
76 lines (73 loc) · 1.37 KB
/
servicebus_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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
package azure
import (
"strings"
"testing"
)
func TestValidateServiceBusTopicName(t *testing.T) {
tests := []struct {
name string
input string
valid bool
}{
{
name: "Empty value",
input: "",
valid: false,
},
{
name: "Invalid name with only 1 letter",
input: "a",
valid: true,
},
{
name: "Invalid name starts with underscore",
input: "_a",
valid: false,
},
{
name: "Invalid name ends with period",
input: "a.",
valid: false,
},
{
name: "Valid name with numbers",
input: "12345",
valid: true,
},
{
name: "Valid name with only 1 number",
input: "1",
valid: true,
},
{
name: "Valid name with hyphens",
input: "malcolm-in-the-middle",
valid: true,
},
{
name: "Valid name with 259 characters",
input: strings.Repeat("w", 259),
valid: true,
},
{
name: "Valid name with 260 characters",
input: strings.Repeat("w", 260),
valid: true,
},
{
name: "Invalid name with 261 characters",
input: strings.Repeat("w", 261),
valid: false,
},
}
var validationFunction = ValidateServiceBusTopicName()
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
_, err := validationFunction(tt.input, "name")
valid := err == nil
if valid != tt.valid {
t.Errorf("Expected valid status %t but got %t for input %s", tt.valid, valid, tt.input)
}
})
}
}