Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
ollama
Commits
2e4da8ee
Commit
2e4da8ee
authored
May 31, 2024
by
Josh Yan
Browse files
added tests for IsValidNamespace
parent
c365f195
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
0 deletions
+27
-0
types/model/name_test.go
types/model/name_test.go
+27
-0
No files found.
types/model/name_test.go
View file @
2e4da8ee
...
@@ -385,3 +385,30 @@ func FuzzName(f *testing.F) {
...
@@ -385,3 +385,30 @@ func FuzzName(f *testing.F) {
})
})
}
}
func
TestIsValidNamespace
(
t
*
testing
.
T
)
{
cases
:=
[]
struct
{
username
string
expected
bool
}{
{
""
,
false
},
{
"a"
,
true
},
{
"a:b"
,
false
},
{
"a/b"
,
false
},
{
"a:b/c"
,
false
},
{
"a/b:c"
,
false
},
{
"a/b:c"
,
false
},
{
"a/b:c/d"
,
false
},
{
"a/b:c/d@e"
,
false
},
{
"a/b:c/d@sha256-100"
,
false
},
{
"himynameisjoe"
,
true
},
{
"himynameisreallyreallyreallyreallylongbutitshouldstillbevalid"
,
true
},
}
for
_
,
tt
:=
range
cases
{
t
.
Run
(
tt
.
username
,
func
(
t
*
testing
.
T
)
{
if
got
:=
IsValidNamespace
(
tt
.
username
);
got
!=
tt
.
expected
{
t
.
Errorf
(
"IsValidName(%q) = %v; want %v"
,
tt
.
username
,
got
,
tt
.
expected
)
}
})
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment