1
- package httpapi_test
1
+ package codersdk_test
2
2
3
3
import (
4
4
"strings"
7
7
"github.com/stretchr/testify/assert"
8
8
"github.com/stretchr/testify/require"
9
9
10
- "github.com/coder/coder/v2/coderd/httpapi "
10
+ "github.com/coder/coder/v2/codersdk "
11
11
"github.com/coder/coder/v2/testutil"
12
12
)
13
13
@@ -62,7 +62,7 @@ func TestUsernameValid(t *testing.T) {
62
62
testCase := testCase
63
63
t .Run (testCase .Username , func (t * testing.T ) {
64
64
t .Parallel ()
65
- valid := httpapi .NameValid (testCase .Username )
65
+ valid := codersdk .NameValid (testCase .Username )
66
66
require .Equal (t , testCase .Valid , valid == nil )
67
67
})
68
68
}
@@ -117,7 +117,7 @@ func TestTemplateDisplayNameValid(t *testing.T) {
117
117
testCase := testCase
118
118
t .Run (testCase .Name , func (t * testing.T ) {
119
119
t .Parallel ()
120
- valid := httpapi .DisplayNameValid (testCase .Name )
120
+ valid := codersdk .DisplayNameValid (testCase .Name )
121
121
require .Equal (t , testCase .Valid , valid == nil )
122
122
})
123
123
}
@@ -158,7 +158,7 @@ func TestTemplateVersionNameValid(t *testing.T) {
158
158
testCase := testCase
159
159
t .Run (testCase .Name , func (t * testing.T ) {
160
160
t .Parallel ()
161
- valid := httpapi .TemplateVersionNameValid (testCase .Name )
161
+ valid := codersdk .TemplateVersionNameValid (testCase .Name )
162
162
require .Equal (t , testCase .Valid , valid == nil )
163
163
})
164
164
}
@@ -169,7 +169,7 @@ func TestGeneratedTemplateVersionNameValid(t *testing.T) {
169
169
170
170
for i := 0 ; i < 1000 ; i ++ {
171
171
name := testutil .GetRandomName (t )
172
- err := httpapi .TemplateVersionNameValid (name )
172
+ err := codersdk .TemplateVersionNameValid (name )
173
173
require .NoError (t , err , "invalid template version name: %s" , name )
174
174
}
175
175
}
@@ -199,9 +199,9 @@ func TestFrom(t *testing.T) {
199
199
testCase := testCase
200
200
t .Run (testCase .From , func (t * testing.T ) {
201
201
t .Parallel ()
202
- converted := httpapi .UsernameFrom (testCase .From )
202
+ converted := codersdk .UsernameFrom (testCase .From )
203
203
t .Log (converted )
204
- valid := httpapi .NameValid (converted )
204
+ valid := codersdk .NameValid (converted )
205
205
require .True (t , valid == nil )
206
206
if testCase .Match == "" {
207
207
require .NotEqual (t , testCase .From , converted )
@@ -245,9 +245,9 @@ func TestUserRealNameValid(t *testing.T) {
245
245
testCase := testCase
246
246
t .Run (testCase .Name , func (t * testing.T ) {
247
247
t .Parallel ()
248
- err := httpapi .UserRealNameValid (testCase .Name )
249
- norm := httpapi .NormalizeRealUsername (testCase .Name )
250
- normErr := httpapi .UserRealNameValid (norm )
248
+ err := codersdk .UserRealNameValid (testCase .Name )
249
+ norm := codersdk .NormalizeRealUsername (testCase .Name )
250
+ normErr := codersdk .UserRealNameValid (norm )
251
251
assert .NoError (t , normErr )
252
252
assert .Equal (t , testCase .Valid , err == nil )
253
253
assert .Equal (t , testCase .Valid , norm == testCase .Name , "invalid name should be different after normalization" )
0 commit comments