1- package httpapi_test
1+ package codersdk_test
22
33import (
44"strings"
77"github.com/stretchr/testify/assert"
88"github.com/stretchr/testify/require"
99
10- "github.com/coder/coder/v2/coderd/httpapi "
10+ "github.com/coder/coder/v2/codersdk "
1111"github.com/coder/coder/v2/testutil"
1212)
1313
@@ -62,7 +62,7 @@ func TestUsernameValid(t *testing.T) {
6262testCase := testCase
6363t .Run (testCase .Username ,func (t * testing.T ) {
6464t .Parallel ()
65- valid := httpapi .NameValid (testCase .Username )
65+ valid := codersdk .NameValid (testCase .Username )
6666require .Equal (t ,testCase .Valid ,valid == nil )
6767})
6868}
@@ -117,7 +117,7 @@ func TestTemplateDisplayNameValid(t *testing.T) {
117117testCase := testCase
118118t .Run (testCase .Name ,func (t * testing.T ) {
119119t .Parallel ()
120- valid := httpapi .DisplayNameValid (testCase .Name )
120+ valid := codersdk .DisplayNameValid (testCase .Name )
121121require .Equal (t ,testCase .Valid ,valid == nil )
122122})
123123}
@@ -158,7 +158,7 @@ func TestTemplateVersionNameValid(t *testing.T) {
158158testCase := testCase
159159t .Run (testCase .Name ,func (t * testing.T ) {
160160t .Parallel ()
161- valid := httpapi .TemplateVersionNameValid (testCase .Name )
161+ valid := codersdk .TemplateVersionNameValid (testCase .Name )
162162require .Equal (t ,testCase .Valid ,valid == nil )
163163})
164164}
@@ -169,7 +169,7 @@ func TestGeneratedTemplateVersionNameValid(t *testing.T) {
169169
170170for i := 0 ;i < 1000 ;i ++ {
171171name := testutil .GetRandomName (t )
172- err := httpapi .TemplateVersionNameValid (name )
172+ err := codersdk .TemplateVersionNameValid (name )
173173require .NoError (t ,err ,"invalid template version name: %s" ,name )
174174}
175175}
@@ -199,9 +199,9 @@ func TestFrom(t *testing.T) {
199199testCase := testCase
200200t .Run (testCase .From ,func (t * testing.T ) {
201201t .Parallel ()
202- converted := httpapi .UsernameFrom (testCase .From )
202+ converted := codersdk .UsernameFrom (testCase .From )
203203t .Log (converted )
204- valid := httpapi .NameValid (converted )
204+ valid := codersdk .NameValid (converted )
205205require .True (t ,valid == nil )
206206if testCase .Match == "" {
207207require .NotEqual (t ,testCase .From ,converted )
@@ -245,9 +245,9 @@ func TestUserRealNameValid(t *testing.T) {
245245testCase := testCase
246246t .Run (testCase .Name ,func (t * testing.T ) {
247247t .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 )
251251assert .NoError (t ,normErr )
252252assert .Equal (t ,testCase .Valid ,err == nil )
253253assert .Equal (t ,testCase .Valid ,norm == testCase .Name ,"invalid name should be different after normalization" )