Finish audit remediation and prepare v0.6.0
This commit is contained in:
@@ -117,7 +117,7 @@ func (r *sourceRepository) GetPromptDefinition(ctx context.Context, id string, v
|
||||
relPath := r.source.displayPath(fullPath)
|
||||
data, err := r.source.readDefinition(fullPath)
|
||||
if err != nil {
|
||||
continue
|
||||
return nil, fmt.Errorf("failed to read prompt definition file %s: %w", relPath, err)
|
||||
}
|
||||
raw, err := decodePromptDefinition(data)
|
||||
if err != nil {
|
||||
|
||||
@@ -460,6 +460,42 @@ type recordingFS struct {
|
||||
opened []string
|
||||
}
|
||||
|
||||
func TestPromptRepositoryReturnsDefinitionReadFailures(t *testing.T) {
|
||||
readErr := errors.New("definition read failed")
|
||||
fsys := &definitionReadFailureFS{
|
||||
FS: fstest.MapFS{
|
||||
"prompts/target.yaml": &fstest.MapFile{Data: []byte("unread")},
|
||||
},
|
||||
target: "prompts/target.yaml",
|
||||
err: readErr,
|
||||
}
|
||||
repo := NewFSRepository(fsys, "prompts")
|
||||
|
||||
definition, err := repo.GetPromptDefinition(context.Background(), "target", "1")
|
||||
if definition != nil || !errors.Is(err, readErr) {
|
||||
t.Fatalf("GetPromptDefinition() = (%#v, %v), want nil and definition read error", definition, err)
|
||||
}
|
||||
if errors.Is(err, ErrPromptDefinitionNotFound) {
|
||||
t.Fatalf("definition read error was classified as absence: %v", err)
|
||||
}
|
||||
if !strings.Contains(err.Error(), "target.yaml") {
|
||||
t.Fatalf("definition read error lacks source context: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
type definitionReadFailureFS struct {
|
||||
fs.FS
|
||||
target string
|
||||
err error
|
||||
}
|
||||
|
||||
func (f *definitionReadFailureFS) Open(name string) (fs.File, error) {
|
||||
if name == f.target {
|
||||
return nil, f.err
|
||||
}
|
||||
return f.FS.Open(name)
|
||||
}
|
||||
|
||||
func (f *recordingFS) Open(name string) (fs.File, error) {
|
||||
f.mu.Lock()
|
||||
f.opened = append(f.opened, name)
|
||||
|
||||
Reference in New Issue
Block a user