Rename files, add nil item check

This commit is contained in:
Abhishek Pandey 2023-12-01 22:33:49 -08:00
parent 8025d4aa9a
commit efe8a9e1d2
2 changed files with 17 additions and 1 deletions

View File

@ -20,7 +20,6 @@ type LiteDriveItemable interface {
GetId() *string GetId() *string
GetName() *string GetName() *string
GetSize() *int64 GetSize() *int64
// TODO(pandeyabs): replace with any
GetFolder() interface{} GetFolder() interface{}
GetPackageEscaped() interface{} GetPackageEscaped() interface{}
GetShared() interface{} GetShared() interface{}
@ -204,6 +203,10 @@ var downloadURLKeys = []string{
} }
func ToLiteDriveItemable(item models.DriveItemable) LiteDriveItemable { func ToLiteDriveItemable(item models.DriveItemable) LiteDriveItemable {
if item == nil {
return nil
}
cdi := &driveItem{ cdi := &driveItem{
id: strings.Clone(ptr.Val(item.GetId())), id: strings.Clone(ptr.Val(item.GetId())),
name: strings.Clone(ptr.Val(item.GetName())), name: strings.Clone(ptr.Val(item.GetName())),

View File

@ -39,6 +39,19 @@ func (suite *driveUnitSuite) TestToLiteDriveItemable() {
expected models.DriveItemable, expected models.DriveItemable,
got LiteDriveItemable) got LiteDriveItemable)
}{ }{
{
name: "nil item",
itemFunc: func() models.DriveItemable {
return nil
},
validateFunc: func(
t *testing.T,
expected models.DriveItemable,
got LiteDriveItemable,
) {
require.Nil(t, got)
},
},
{ {
name: "uninitialized values", name: "uninitialized values",
itemFunc: func() models.DriveItemable { itemFunc: func() models.DriveItemable {