MCPcopy Index your code
hub / github.com/coder/coder / TestTemplateDisplayNameValid

Function TestTemplateDisplayNameValid

codersdk/name_test.go:71–123  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

69}
70
71func TestTemplateDisplayNameValid(t *testing.T) {
72 t.Parallel()
73 // Tests whether display names are valid.
74 testCases := []struct {
75 Name string
76 Valid bool
77 }{
78 {"", true},
79 {"1", true},
80 {"12", true},
81 {"1 2", true},
82 {"123 456", true},
83 {"1234 678901234567890", true},
84 {"<b> </b>", true},
85 {"S", true},
86 {"a1", true},
87 {"a1K2", true},
88 {"!!!!1 ?????", true},
89 {"k\r\rm", true},
90 {"abcdefghijklmnopqrst", true},
91 {"Wow Test", true},
92 {"abcdefghijklmnopqrstu-", true},
93 {"a1b2c3d4e5f6g7h8i9j0k-", true},
94 {"BANANAS_wow", true},
95 {"test--now", true},
96 {"123456789012345678901234567890123", true},
97 {"1234567890123456789012345678901234567890123456789012345678901234", true},
98 {"-a1b2c3d4e5f6g7h8i9j0k", true},
99
100 {" ", false},
101 {"\t", false},
102 {"\r\r", false},
103 {"\t1 ", false},
104 {" a", false},
105 {"\ra ", false},
106 {" 1", false},
107 {"1 ", false},
108 {" aa", false},
109 {"aa\r", false},
110 {" 12", false},
111 {"12 ", false},
112 {"\fa1", false},
113 {"a1\t", false},
114 {"12345678901234567890123456789012345678901234567890123456789012345", false},
115 }
116 for _, testCase := range testCases {
117 t.Run(testCase.Name, func(t *testing.T) {
118 t.Parallel()
119 valid := codersdk.DisplayNameValid(testCase.Name)
120 require.Equal(t, testCase.Valid, valid == nil)
121 })
122 }
123}
124
125func TestTemplateVersionNameValid(t *testing.T) {
126 t.Parallel()

Callers

nothing calls this directly

Calls 3

DisplayNameValidFunction · 0.92
RunMethod · 0.65
EqualMethod · 0.45

Tested by

no test coverage detected