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
b27268aa
Commit
b27268aa
authored
Jun 10, 2024
by
Michael Yang
Browse files
add test
parent
cddc6338
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
33 additions
and
0 deletions
+33
-0
server/routes_delete_test.go
server/routes_delete_test.go
+33
-0
No files found.
server/routes_delete_test.go
View file @
b27268aa
package
server
package
server
import
(
import
(
"bytes"
"encoding/json"
"fmt"
"fmt"
"net/http"
"net/http"
"path/filepath"
"path/filepath"
"testing"
"testing"
"github.com/ollama/ollama/api"
"github.com/ollama/ollama/api"
"github.com/ollama/ollama/types/model"
)
)
func
TestDelete
(
t
*
testing
.
T
)
{
func
TestDelete
(
t
*
testing
.
T
)
{
...
@@ -69,3 +72,33 @@ func TestDelete(t *testing.T) {
...
@@ -69,3 +72,33 @@ func TestDelete(t *testing.T) {
checkFileExists
(
t
,
filepath
.
Join
(
p
,
"manifests"
,
"*"
,
"*"
,
"*"
,
"*"
),
[]
string
{})
checkFileExists
(
t
,
filepath
.
Join
(
p
,
"manifests"
,
"*"
,
"*"
,
"*"
,
"*"
),
[]
string
{})
checkFileExists
(
t
,
filepath
.
Join
(
p
,
"blobs"
,
"*"
),
[]
string
{})
checkFileExists
(
t
,
filepath
.
Join
(
p
,
"blobs"
,
"*"
),
[]
string
{})
}
}
func
TestDeleteDuplicateLayers
(
t
*
testing
.
T
)
{
p
:=
t
.
TempDir
()
t
.
Setenv
(
"OLLAMA_MODELS"
,
p
)
var
s
Server
n
:=
model
.
ParseName
(
"test"
)
var
b
bytes
.
Buffer
if
err
:=
json
.
NewEncoder
(
&
b
)
.
Encode
(
&
ConfigV2
{});
err
!=
nil
{
t
.
Fatal
(
err
)
}
config
,
err
:=
NewLayer
(
&
b
,
"application/vnd.docker.container.image.v1+json"
)
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
// create a manifest with duplicate layers
if
err
:=
WriteManifest
(
n
,
config
,
[]
*
Layer
{
config
});
err
!=
nil
{
t
.
Fatal
(
err
)
}
w
:=
createRequest
(
t
,
s
.
DeleteModelHandler
,
api
.
DeleteRequest
{
Name
:
"test"
})
if
w
.
Code
!=
http
.
StatusOK
{
t
.
Errorf
(
"expected status code 200, actual %d"
,
w
.
Code
)
}
checkFileExists
(
t
,
filepath
.
Join
(
p
,
"manifests"
,
"*"
,
"*"
,
"*"
,
"*"
),
[]
string
{})
}
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