Skip to content

feat: add to workspace fileinfo #85

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions workspace.go
Original file line number Diff line number Diff line change
Expand Up @@ -252,4 +252,5 @@ type FileInfo struct {
Name string
Size int64
ModTime time.Time
MimeType string
}
8 changes: 8 additions & 0 deletions workspace_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@ func TestWriteReadAndDeleteFileFromWorkspace(t *testing.T) {
t.Errorf("Unexpected file mod time: %v", fileInfo.ModTime)
}

if fileInfo.MimeType != "text/plain" {
t.Errorf("Unexpected file mime type: %s", fileInfo.MimeType)
}

// Ensure we get the error we expect when trying to read a non-existent file
_, err = g.ReadFileInWorkspace(context.Background(), "test1.txt", ReadFileInWorkspaceOptions{WorkspaceID: id})
if nf := (*NotFoundInWorkspaceError)(nil); !errors.As(err, &nf) {
Expand Down Expand Up @@ -226,6 +230,10 @@ func TestWriteReadAndDeleteFileFromWorkspaceS3(t *testing.T) {
t.Errorf("Unexpected file mod time: %v", fileInfo.ModTime)
}

if fileInfo.MimeType != "text/plain" {
t.Errorf("Unexpected file mime type: %s", fileInfo.MimeType)
}

// Ensure we get the error we expect when trying to read a non-existent file
_, err = g.ReadFileInWorkspace(context.Background(), "test1.txt", ReadFileInWorkspaceOptions{WorkspaceID: id})
if nf := (*NotFoundInWorkspaceError)(nil); !errors.As(err, &nf) {
Expand Down
Loading