Skip to content

Commit ffe7fa6

Browse files
committed
fix: update file path annotation to use base name and enhance tests
1 parent ee0bcb8 commit ffe7fa6

File tree

2 files changed

+23
-2
lines changed

2 files changed

+23
-2
lines changed

pkg/distribution/internal/gguf/model_test.go

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package gguf_test
22

33
import (
44
"encoding/json"
5+
"path"
56
"path/filepath"
67
"testing"
78

@@ -108,10 +109,15 @@ func TestGGUF(t *testing.T) {
108109
}
109110

110111
// Check for required annotation keys
111-
if _, ok := layer.Annotations[types.AnnotationFilePath]; !ok {
112+
filePath, ok := layer.Annotations[types.AnnotationFilePath]
113+
if !ok {
112114
t.Errorf("Expected annotation %s to be present", types.AnnotationFilePath)
113115
}
114116

117+
if filePath != path.Base("dummy.gguf") {
118+
t.Errorf("Expected file path annotation to be '%s', got '%s'", path.Base("dummy.gguf"), filePath)
119+
}
120+
115121
if _, ok := layer.Annotations[types.AnnotationFileMetadata]; !ok {
116122
t.Errorf("Expected annotation %s to be present", types.AnnotationFileMetadata)
117123
}
@@ -136,6 +142,21 @@ func TestGGUF(t *testing.T) {
136142
if metadata.Size == 0 {
137143
t.Error("Expected file size to be non-zero")
138144
}
145+
if metadata.Typeflag != 0 {
146+
t.Errorf("Expected Typeflag 0 for regular file, got %d", metadata.Typeflag)
147+
}
148+
if metadata.Mode == 0 {
149+
t.Error("Expected file mode to be non-zero")
150+
}
151+
if metadata.ModTime.IsZero() {
152+
t.Error("Expected modification time to be set")
153+
}
154+
if metadata.Uid != 0 {
155+
t.Error("Expected Uid to be set with default 0")
156+
}
157+
if metadata.Gid != 0 {
158+
t.Error("Expected Gid to be set with default 0")
159+
}
139160
})
140161
})
141162
}

pkg/distribution/internal/partial/layer.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ func NewLayer(path string, mt ggcrtypes.MediaType) (*Layer, error) {
5555

5656
// Create annotations
5757
annotations := map[string]string{
58-
types.AnnotationFilePath: path,
58+
types.AnnotationFilePath: filepath.Base(path),
5959
types.AnnotationFileMetadata: string(metadataJSON),
6060
types.AnnotationMediaTypeUntested: "false", // Media types are tested in this implementation
6161
}

0 commit comments

Comments
 (0)