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
a7248f6e
Commit
a7248f6e
authored
Apr 16, 2024
by
Michael Yang
Browse files
update tests
parent
9685c345
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
25 deletions
+21
-25
integration/utils_test.go
integration/utils_test.go
+1
-1
server/routes_test.go
server/routes_test.go
+20
-24
No files found.
integration/utils_test.go
View file @
a7248f6e
...
@@ -107,7 +107,7 @@ func startServer(ctx context.Context, ollamaHost string) error {
...
@@ -107,7 +107,7 @@ func startServer(ctx context.Context, ollamaHost string) error {
if
tmp
:=
os
.
Getenv
(
"OLLAMA_HOST"
);
tmp
!=
ollamaHost
{
if
tmp
:=
os
.
Getenv
(
"OLLAMA_HOST"
);
tmp
!=
ollamaHost
{
slog
.
Info
(
"setting env"
,
"OLLAMA_HOST"
,
ollamaHost
)
slog
.
Info
(
"setting env"
,
"OLLAMA_HOST"
,
ollamaHost
)
os
.
Setenv
(
"OLLAMA_HOST"
,
ollamaHost
)
t
.
Setenv
(
"OLLAMA_HOST"
,
ollamaHost
)
}
}
slog
.
Info
(
"starting server"
,
"url"
,
ollamaHost
)
slog
.
Info
(
"starting server"
,
"url"
,
ollamaHost
)
...
...
server/routes_test.go
View file @
a7248f6e
...
@@ -124,14 +124,12 @@ func Test_Routes(t *testing.T) {
...
@@ -124,14 +124,12 @@ func Test_Routes(t *testing.T) {
Method
:
http
.
MethodPost
,
Method
:
http
.
MethodPost
,
Path
:
"/api/create"
,
Path
:
"/api/create"
,
Setup
:
func
(
t
*
testing
.
T
,
req
*
http
.
Request
)
{
Setup
:
func
(
t
*
testing
.
T
,
req
*
http
.
Request
)
{
f
,
err
:=
os
.
CreateTemp
(
t
.
TempDir
(),
"ollama-model"
)
fname
:=
createTestFile
(
t
,
"ollama-model"
)
assert
.
Nil
(
t
,
err
)
defer
f
.
Close
()
stream
:=
false
stream
:=
false
createReq
:=
api
.
CreateRequest
{
createReq
:=
api
.
CreateRequest
{
Name
:
"t-bone"
,
Name
:
"t-bone"
,
Modelfile
:
fmt
.
Sprintf
(
"FROM %s"
,
f
.
N
ame
()
),
Modelfile
:
fmt
.
Sprintf
(
"FROM %s"
,
f
n
ame
),
Stream
:
&
stream
,
Stream
:
&
stream
,
}
}
jsonData
,
err
:=
json
.
Marshal
(
createReq
)
jsonData
,
err
:=
json
.
Marshal
(
createReq
)
...
@@ -216,27 +214,25 @@ func Test_Routes(t *testing.T) {
...
@@ -216,27 +214,25 @@ func Test_Routes(t *testing.T) {
httpSrv
:=
httptest
.
NewServer
(
router
)
httpSrv
:=
httptest
.
NewServer
(
router
)
t
.
Cleanup
(
httpSrv
.
Close
)
t
.
Cleanup
(
httpSrv
.
Close
)
workDir
,
err
:=
os
.
MkdirTemp
(
""
,
"ollama-test"
)
t
.
Setenv
(
"OLLAMA_MODELS"
,
t
.
TempDir
())
assert
.
Nil
(
t
,
err
)
defer
os
.
RemoveAll
(
workDir
)
os
.
Setenv
(
"OLLAMA_MODELS"
,
workDir
)
for
_
,
tc
:=
range
testCases
{
for
_
,
tc
:=
range
testCases
{
t
.
Logf
(
"Running Test: [%s]"
,
tc
.
Name
)
t
.
Run
(
tc
.
Name
,
func
(
t
*
testing
.
T
)
{
u
:=
httpSrv
.
URL
+
tc
.
Path
u
:=
httpSrv
.
URL
+
tc
.
Path
req
,
err
:=
http
.
NewRequestWithContext
(
context
.
TODO
(),
tc
.
Method
,
u
,
nil
)
req
,
err
:=
http
.
NewRequestWithContext
(
context
.
TODO
(),
tc
.
Method
,
u
,
nil
)
assert
.
Nil
(
t
,
err
)
assert
.
Nil
(
t
,
err
)
if
tc
.
Setup
!=
nil
{
if
tc
.
Setup
!=
nil
{
tc
.
Setup
(
t
,
req
)
tc
.
Setup
(
t
,
req
)
}
}
resp
,
err
:=
httpSrv
.
Client
()
.
Do
(
req
)
resp
,
err
:=
httpSrv
.
Client
()
.
Do
(
req
)
assert
.
Nil
(
t
,
err
)
assert
.
Nil
(
t
,
err
)
defer
resp
.
Body
.
Close
()
defer
resp
.
Body
.
Close
()
if
tc
.
Expected
!=
nil
{
if
tc
.
Expected
!=
nil
{
tc
.
Expected
(
t
,
resp
)
tc
.
Expected
(
t
,
resp
)
}
}
})
}
}
}
}
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