Skip to content
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
2 changes: 1 addition & 1 deletion cmd/account_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ func testFullAccount() *users.FullAccount {
nil,
)
account.ProfilePhotoUrl = "https://dropbox.example/photo"
account.Team = users.NewFullTeam("team-id", "Team Name", nil, nil)
account.Team = users.NewFullTeam("team-id", "Team Name", nil, nil, nil)
account.TeamMemberId = "dbmid:member"
return account
}
Expand Down
6 changes: 3 additions & 3 deletions cmd/cp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ func TestCpJSONOutputsRelocationResults(t *testing.T) {
return nil, fmt.Errorf("path/not_found/")
},
copyV2Fn: func(arg *files.RelocationArg) (*files.RelocationResult, error) {
metadata := files.NewFileMetadata("file-copy.txt", "id:file-copy", time.Time{}, time.Time{}, "rev-copy", 42)
metadata := files.NewFileMetadata("file-copy.txt", "id:file-copy", dropbox.DBXTime(time.Time{}), dropbox.DBXTime(time.Time{}), "rev-copy", 42)
metadata.PathDisplay = arg.ToPath
metadata.PathLower = strings.ToLower(arg.ToPath)
return files.NewRelocationResult(metadata), nil
Expand Down Expand Up @@ -241,7 +241,7 @@ func TestCpJSONMultipleSourcesOutputsMultipleResults(t *testing.T) {
stubFilesClient(t, &mockFilesClient{
copyV2Fn: func(arg *files.RelocationArg) (*files.RelocationResult, error) {
name := path.Base(arg.ToPath)
metadata := files.NewFileMetadata(name, "id:"+name, time.Time{}, time.Time{}, "rev", 1)
metadata := files.NewFileMetadata(name, "id:"+name, dropbox.DBXTime(time.Time{}), dropbox.DBXTime(time.Time{}), "rev", 1)
metadata.PathDisplay = arg.ToPath
metadata.PathLower = strings.ToLower(arg.ToPath)
return files.NewRelocationResult(metadata), nil
Expand Down Expand Up @@ -585,7 +585,7 @@ func decodeRelocationOutput(t *testing.T, data []byte) relocationOutput {
}

func relocationTestFileMetadata(pathDisplay string, size uint64) *files.FileMetadata {
metadata := files.NewFileMetadata(path.Base(pathDisplay), "id:"+path.Base(pathDisplay), time.Time{}, time.Time{}, "rev", size)
metadata := files.NewFileMetadata(path.Base(pathDisplay), "id:"+path.Base(pathDisplay), dropbox.DBXTime(time.Time{}), dropbox.DBXTime(time.Time{}), "rev", size)
metadata.PathDisplay = pathDisplay
metadata.PathLower = strings.ToLower(pathDisplay)
return metadata
Expand Down
4 changes: 2 additions & 2 deletions cmd/format.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ func formatTime(t time.Time, opts listOptions) string {

func getTime(e *files.FileMetadata, opts listOptions) time.Time {
if opts.timeField == "client" {
return e.ClientModified
return time.Time(e.ClientModified)
}
return e.ServerModified
return time.Time(e.ServerModified)
}

func sortEntries(entries []files.IsMetadata, opts listOptions) {
Expand Down
21 changes: 11 additions & 10 deletions cmd/format_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"testing"
"time"

"github.com/dropbox/dropbox-sdk-go-unofficial/v6/dropbox"
"github.com/dropbox/dropbox-sdk-go-unofficial/v6/dropbox/files"
)

Expand Down Expand Up @@ -40,8 +41,8 @@ func TestGetTimeServer(t *testing.T) {
serverTime := time.Date(2025, 1, 1, 0, 0, 0, 0, time.UTC)
clientTime := time.Date(2024, 6, 1, 0, 0, 0, 0, time.UTC)
meta := &files.FileMetadata{
ServerModified: serverTime,
ClientModified: clientTime,
ServerModified: dropbox.DBXTime(serverTime),
ClientModified: dropbox.DBXTime(clientTime),
}

got := getTime(meta, listOptions{timeField: "server"})
Expand All @@ -59,8 +60,8 @@ func TestGetTimeClient(t *testing.T) {
serverTime := time.Date(2025, 1, 1, 0, 0, 0, 0, time.UTC)
clientTime := time.Date(2024, 6, 1, 0, 0, 0, 0, time.UTC)
meta := &files.FileMetadata{
ServerModified: serverTime,
ClientModified: clientTime,
ServerModified: dropbox.DBXTime(serverTime),
ClientModified: dropbox.DBXTime(clientTime),
}

got := getTime(meta, listOptions{timeField: "client"})
Expand Down Expand Up @@ -103,11 +104,11 @@ func TestSortEntriesByTime(t *testing.T) {
entries := []files.IsMetadata{
&files.FileMetadata{
Metadata: files.Metadata{PathDisplay: "/new"},
ServerModified: time.Date(2025, 6, 1, 0, 0, 0, 0, time.UTC),
ServerModified: dropbox.DBXTime(time.Date(2025, 6, 1, 0, 0, 0, 0, time.UTC)),
},
&files.FileMetadata{
Metadata: files.Metadata{PathDisplay: "/old"},
ServerModified: time.Date(2020, 1, 1, 0, 0, 0, 0, time.UTC),
ServerModified: dropbox.DBXTime(time.Date(2020, 1, 1, 0, 0, 0, 0, time.UTC)),
},
&files.FolderMetadata{Metadata: files.Metadata{PathDisplay: "/folder"}},
}
Expand Down Expand Up @@ -169,7 +170,7 @@ func TestFormatFileMetadataWithOptsShort(t *testing.T) {
Metadata: files.Metadata{PathDisplay: "/test.txt"},
Rev: "abc",
Size: 4096,
ServerModified: ts,
ServerModified: dropbox.DBXTime(ts),
}

got := formatFileMetadataWithOpts(meta, listOptions{long: false})
Expand All @@ -185,7 +186,7 @@ func TestFormatFileMetadataWithOptsLongShortTime(t *testing.T) {
Metadata: files.Metadata{PathDisplay: "/test.txt"},
Rev: "abc",
Size: 4096,
ServerModified: ts,
ServerModified: dropbox.DBXTime(ts),
}

got := formatFileMetadataWithOpts(meta, listOptions{long: true, timeFormat: "short"})
Expand All @@ -204,8 +205,8 @@ func TestFormatFileMetadataWithOptsClientTime(t *testing.T) {
Metadata: files.Metadata{PathDisplay: "/test.txt"},
Rev: "abc",
Size: 1024,
ServerModified: server,
ClientModified: client,
ServerModified: dropbox.DBXTime(server),
ClientModified: dropbox.DBXTime(client),
}

got := formatFileMetadataWithOpts(meta, listOptions{long: true, timeField: "client", timeFormat: "short"})
Expand Down
4 changes: 2 additions & 2 deletions cmd/json_metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ func jsonMetadataFromDropbox(metadata files.IsMetadata) (jsonMetadata, error) {
ID: m.Id,
Rev: m.Rev,
Size: &size,
ServerModified: jsonTime(m.ServerModified),
ClientModified: jsonTime(m.ClientModified),
ServerModified: jsonTime(time.Time(m.ServerModified)),
ClientModified: jsonTime(time.Time(m.ClientModified)),
}, nil
case *files.FolderMetadata:
if m == nil {
Expand Down
5 changes: 3 additions & 2 deletions cmd/json_metadata_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"testing"
"time"

"github.com/dropbox/dropbox-sdk-go-unofficial/v6/dropbox"
"github.com/dropbox/dropbox-sdk-go-unofficial/v6/dropbox/files"
)

Expand All @@ -20,8 +21,8 @@ func TestJSONMetadataFromDropboxFile(t *testing.T) {
Id: "id:abc",
Rev: "rev123",
Size: 0,
ClientModified: clientModified,
ServerModified: serverModified,
ClientModified: dropbox.DBXTime(clientModified),
ServerModified: dropbox.DBXTime(serverModified),
}

got, err := jsonMetadataFromDropbox(metadata)
Expand Down
8 changes: 4 additions & 4 deletions cmd/ls_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ func TestFormatFileMetadataLongIncludesFields(t *testing.T) {
},
Rev: "rev999",
Size: 2048,
ServerModified: ts,
ServerModified: dropbox.DBXTime(ts),
}

got := formatFileMetadata(meta, true)
Expand Down Expand Up @@ -363,7 +363,7 @@ func TestLsOnlyDeletedLimitCountsFilteredEntries(t *testing.T) {
Id: "id:" + arg.Path,
Rev: "rev:" + arg.Path,
},
}), nil
}, false), nil
},
}
stubFilesClient(t, mock)
Expand Down Expand Up @@ -421,7 +421,7 @@ func TestLsOnlyDeletedLimitTruncatesFilteredPage(t *testing.T) {
Id: "id:" + arg.Path,
Rev: "rev:" + arg.Path,
},
}), nil
}, false), nil
},
}
stubFilesClient(t, mock)
Expand Down Expand Up @@ -588,7 +588,7 @@ func TestLsJSONDeletedEntryIsStructured(t *testing.T) {
Rev: "rev-removed",
Size: 9,
},
}), nil
}, false), nil
},
}
stubFilesClient(t, mock)
Expand Down
3 changes: 3 additions & 0 deletions cmd/mock_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,9 @@ func (m *mockFilesClient) UnlockFileBatch(arg *files.UnlockFileBatchArg) (*files
func (m *mockFilesClient) UploadSessionAppend(arg *files.UploadSessionCursor, content io.Reader) error {
return nil
}
func (m *mockFilesClient) UploadSessionAppendBatch(arg *files.UploadSessionAppendBatchArg, content io.Reader) (*files.UploadSessionAppendBatchResult, error) {
return nil, nil
}
func (m *mockFilesClient) UploadSessionStartBatch(arg *files.UploadSessionStartBatchArg) (*files.UploadSessionStartBatchResult, error) {
return nil, nil
}
Expand Down
5 changes: 3 additions & 2 deletions cmd/mv_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"time"

"github.com/dropbox/dbxcli/v3/internal/output"
"github.com/dropbox/dropbox-sdk-go-unofficial/v6/dropbox"
"github.com/dropbox/dropbox-sdk-go-unofficial/v6/dropbox/files"
"github.com/spf13/cobra"
)
Expand Down Expand Up @@ -86,7 +87,7 @@ func TestMvJSONOutputsRelocationResults(t *testing.T) {
return nil, fmt.Errorf("path/not_found/")
},
moveV2Fn: func(arg *files.RelocationArg) (*files.RelocationResult, error) {
metadata := files.NewFileMetadata("file-moved.txt", "id:file-moved", time.Time{}, time.Time{}, "rev-moved", 64)
metadata := files.NewFileMetadata("file-moved.txt", "id:file-moved", dropbox.DBXTime(time.Time{}), dropbox.DBXTime(time.Time{}), "rev-moved", 64)
metadata.PathDisplay = arg.ToPath
metadata.PathLower = strings.ToLower(arg.ToPath)
return files.NewRelocationResult(metadata), nil
Expand Down Expand Up @@ -120,7 +121,7 @@ func TestMvJSONMultipleSourcesOutputsMultipleResults(t *testing.T) {
stubFilesClient(t, &mockFilesClient{
moveV2Fn: func(arg *files.RelocationArg) (*files.RelocationResult, error) {
name := path.Base(arg.ToPath)
metadata := files.NewFileMetadata(name, "id:"+name, time.Time{}, time.Time{}, "rev", 1)
metadata := files.NewFileMetadata(name, "id:"+name, dropbox.DBXTime(time.Time{}), dropbox.DBXTime(time.Time{}), "rev", 1)
metadata.PathDisplay = arg.ToPath
metadata.PathLower = strings.ToLower(arg.ToPath)
return files.NewRelocationResult(metadata), nil
Expand Down
2 changes: 1 addition & 1 deletion cmd/put.go
Original file line number Diff line number Diff line change
Expand Up @@ -538,7 +538,7 @@ func putFileWithResult(src, dst string, opts putOptions) (putResult, error) {
commitInfo.StrictConflict = ifExists != putIfExistsOverwrite

// The Dropbox API only accepts timestamps in UTC with second precision.
ts := time.Now().UTC().Round(time.Second)
ts := dropbox.DBXTime(time.Now().UTC().Round(time.Second))
commitInfo.ClientModified = &ts

if contentsInfo.Size() > singleShotUploadSizeCutoff {
Expand Down
15 changes: 8 additions & 7 deletions cmd/restore_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"testing"
"time"

"github.com/dropbox/dropbox-sdk-go-unofficial/v6/dropbox"
"github.com/dropbox/dropbox-sdk-go-unofficial/v6/dropbox/files"
"github.com/spf13/cobra"
)
Expand Down Expand Up @@ -49,7 +50,7 @@ func TestRestoreQuietByDefault(t *testing.T) {
return &files.FileMetadata{
Metadata: files.Metadata{PathDisplay: "/Reports/old.pdf", PathLower: "/reports/old.pdf"},
Rev: "current-rev",
ServerModified: serverModified,
ServerModified: dropbox.DBXTime(serverModified),
}, nil
},
}
Expand Down Expand Up @@ -81,7 +82,7 @@ func TestRestoreVerbosePrintsRevisionAndServerModifiedTime(t *testing.T) {
return &files.FileMetadata{
Metadata: files.Metadata{PathDisplay: "/Reports/old.pdf", PathLower: "/reports/old.pdf"},
Rev: "current-rev",
ServerModified: serverModified,
ServerModified: dropbox.DBXTime(serverModified),
}, nil
},
}
Expand All @@ -108,8 +109,8 @@ func TestNewRestoreResultKeepsInputAndMetadata(t *testing.T) {
Id: "id:abc",
Rev: "current-rev",
Size: 123,
ClientModified: clientModified,
ServerModified: serverModified,
ClientModified: dropbox.DBXTime(clientModified),
ServerModified: dropbox.DBXTime(serverModified),
})
if err != nil {
t.Fatal(err)
Expand Down Expand Up @@ -153,8 +154,8 @@ func TestRestoreJSONOutputsInputAndMetadata(t *testing.T) {
Id: "id:abc",
Rev: "current-rev",
Size: 123,
ClientModified: clientModified,
ServerModified: serverModified,
ClientModified: dropbox.DBXTime(clientModified),
ServerModified: dropbox.DBXTime(serverModified),
}, nil
},
}
Expand Down Expand Up @@ -227,7 +228,7 @@ func TestRestoreJSONVerboseDoesNotPrintText(t *testing.T) {
return &files.FileMetadata{
Metadata: files.Metadata{PathDisplay: "/Reports/old.pdf"},
Rev: "current-rev",
ServerModified: time.Date(2026, 6, 17, 12, 30, 0, 0, time.UTC),
ServerModified: dropbox.DBXTime(time.Date(2026, 6, 17, 12, 30, 0, 0, time.UTC)),
}, nil
},
}
Expand Down
11 changes: 6 additions & 5 deletions cmd/revs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"testing"
"time"

"github.com/dropbox/dropbox-sdk-go-unofficial/v6/dropbox"
"github.com/dropbox/dropbox-sdk-go-unofficial/v6/dropbox/files"
"github.com/spf13/cobra"
)
Expand Down Expand Up @@ -35,8 +36,8 @@ func TestRenderRevisionResultsLongModeUsesTimeOptions(t *testing.T) {
Metadata: files.Metadata{PathDisplay: "/report.pdf"},
Rev: "rev-a",
Size: 4096,
ServerModified: serverModified,
ClientModified: clientModified,
ServerModified: dropbox.DBXTime(serverModified),
ClientModified: dropbox.DBXTime(clientModified),
},
}

Expand Down Expand Up @@ -81,7 +82,7 @@ func TestRevsUsesListRevisionsAndCommandOutput(t *testing.T) {
gotLimit = arg.Limit
return files.NewListRevisionsResult(false, []*files.FileMetadata{
{Rev: "rev-c"},
}), nil
}, false), nil
},
})

Expand Down Expand Up @@ -124,9 +125,9 @@ func TestRevsJSONOutputsInputAndResults(t *testing.T) {
Id: "id:file",
Rev: "rev-a",
Size: 42,
ClientModified: clientModified,
ClientModified: dropbox.DBXTime(clientModified),
},
}), nil
}, false), nil
},
})

Expand Down
3 changes: 2 additions & 1 deletion cmd/share-list-folders.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ package cmd
import (
"fmt"
"io"
"time"

"github.com/dropbox/dropbox-sdk-go-unofficial/v6/dropbox"
"github.com/dropbox/dropbox-sdk-go-unofficial/v6/dropbox/sharing"
Expand Down Expand Up @@ -132,7 +133,7 @@ func shareFolderJSONMetadataFromDropbox(entry *sharing.SharedFolderMetadata) sha
OwnerDisplayNames: entry.OwnerDisplayNames,
ParentSharedFolderID: entry.ParentSharedFolderId,
ParentFolderName: entry.ParentFolderName,
TimeInvited: jsonTime(entry.TimeInvited),
TimeInvited: jsonTime(time.Time(entry.TimeInvited)),
}
if entry.AccessType != nil {
result.AccessType = entry.AccessType.Tag
Expand Down
12 changes: 6 additions & 6 deletions cmd/share_create_link_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,8 @@ func TestSharedLinkCreateWithExpiresSetsExpiration(t *testing.T) {
if arg.Settings.Expires == nil {
t.Fatal("expires = nil, want expiration time")
}
if !arg.Settings.Expires.Equal(wantExpires) {
t.Fatalf("expires = %s, want %s", arg.Settings.Expires.Format(time.RFC3339), wantExpires.Format(time.RFC3339))
if !time.Time(*arg.Settings.Expires).Equal(wantExpires) {
t.Fatalf("expires = %s, want %s", time.Time(*arg.Settings.Expires).Format(time.RFC3339), wantExpires.Format(time.RFC3339))
}
return sharedLinkFile("/file.txt", "https://example.com/file"), nil
},
Expand Down Expand Up @@ -299,7 +299,7 @@ func TestSharedLinkCreateWithDisallowDownloadCombinesRawCreateSettings(t *testin
if settings.AllowDownload == nil || *settings.AllowDownload {
t.Fatalf("allow_download = %v, want false", settings.AllowDownload)
}
if settings.Expires == nil || !settings.Expires.Equal(expires) {
if settings.Expires == nil || !time.Time(*settings.Expires).Equal(expires) {
t.Fatalf("expires = %v, want %v", settings.Expires, expires)
}
if settings.Access == nil || settings.Access.Tag != sharing.RequestedLinkAccessLevelViewer {
Expand Down Expand Up @@ -892,7 +892,7 @@ func TestSharedLinkCreateWithExpiresUpdatesExistingLink(t *testing.T) {
existing := sharedLinkFile("/file.txt", "https://example.com/file-old")
mock := &mockSharedLinkClient{
createSharedLinkWithSettingsFn: func(arg *sharing.CreateSharedLinkWithSettingsArg) (sharing.IsSharedLinkMetadata, error) {
if arg.Settings == nil || arg.Settings.Expires == nil || !arg.Settings.Expires.Equal(wantExpires) {
if arg.Settings == nil || arg.Settings.Expires == nil || !time.Time(*arg.Settings.Expires).Equal(wantExpires) {
t.Fatalf("create settings = %#v, want expires %s", arg.Settings, wantExpires.Format(time.RFC3339))
}
return nil, alreadyExistsError(existing)
Expand All @@ -904,7 +904,7 @@ func TestSharedLinkCreateWithExpiresUpdatesExistingLink(t *testing.T) {
if arg.RemoveExpiration {
t.Fatal("RemoveExpiration = true, want false")
}
if arg.Settings == nil || arg.Settings.Expires == nil || !arg.Settings.Expires.Equal(wantExpires) {
if arg.Settings == nil || arg.Settings.Expires == nil || !time.Time(*arg.Settings.Expires).Equal(wantExpires) {
t.Fatalf("modify settings = %#v, want expires %s", arg.Settings, wantExpires.Format(time.RFC3339))
}
return sharedLinkFile("/file.txt", "https://example.com/file-new"), nil
Expand Down Expand Up @@ -1426,7 +1426,7 @@ func TestShareLinkListPaginationRequiresCursor(t *testing.T) {
}

func sharedLinkFile(pathLower string, url string) *sharing.FileLinkMetadata {
link := sharing.NewFileLinkMetadata(url, path.Base(pathLower), nil, time.Time{}, time.Time{}, "rev", 1)
link := sharing.NewFileLinkMetadata(url, path.Base(pathLower), nil, dropbox.DBXTime(time.Time{}), dropbox.DBXTime(time.Time{}), "rev", 1)
link.PathLower = strings.ToLower(pathLower)
return link
}
Expand Down
Loading
Loading