Skip to content

Commit

Permalink
fix: Failed to download some files. #9
Browse files Browse the repository at this point in the history
  • Loading branch information
ManuelReschke committed Oct 18, 2023
1 parent 6e7dba3 commit abc5729
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 30 deletions.
13 changes: 7 additions & 6 deletions pkg/pd/pd_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@ package pd_test

import (
"fmt"
"os"
"testing"

"github.com/ManuelReschke/go-pd/pkg/pd"
"github.com/joho/godotenv"
"github.com/stretchr/testify/assert"
"os"
"testing"
)

const SkipIntegrationTest = "skipping integration test"
Expand Down Expand Up @@ -235,7 +236,7 @@ func TestPD_GetFileInfo(t *testing.T) {
assert.Equal(t, 200, rsp.StatusCode)
assert.Equal(t, true, rsp.Success)
assert.Equal(t, "K1dA8U5W", rsp.ID)
assert.Equal(t, 37621, rsp.Size)
assert.Equal(t, int64(37621), rsp.Size)
assert.Equal(t, "1af93d68009bdfd52e1da100a019a30b5fe083d2d1130919225ad0fd3d1fed0b", rsp.HashSha256)
}

Expand All @@ -260,7 +261,7 @@ func TestPD_GetFileInfo_Integration(t *testing.T) {
assert.Equal(t, 200, rsp.StatusCode)
assert.Equal(t, true, rsp.Success)
assert.Equal(t, fileIDPost, rsp.ID)
assert.Equal(t, 37621, rsp.Size)
assert.Equal(t, int64(37621), rsp.Size)
assert.Equal(t, "1af93d68009bdfd52e1da100a019a30b5fe083d2d1130919225ad0fd3d1fed0b", rsp.HashSha256)
}

Expand Down Expand Up @@ -405,7 +406,7 @@ func TestPD_GetList(t *testing.T) {
assert.Equal(t, true, rsp.Success)
assert.NotEmpty(t, rsp.ID)
assert.Equal(t, "Rust in Peace", rsp.Title)
assert.Equal(t, 123456, rsp.Files[0].Size)
assert.Equal(t, int64(123456), rsp.Files[0].Size)
}

// TestPD_GetList_Integration run a real integration test against the service
Expand All @@ -430,7 +431,7 @@ func TestPD_GetList_Integration(t *testing.T) {
assert.Equal(t, true, rsp.Success)
assert.NotEmpty(t, rsp.ID)
assert.Equal(t, "Test List", rsp.Title)
assert.Equal(t, 37621, rsp.Files[0].Size)
assert.Equal(t, int64(37621), rsp.Files[0].Size)
}

// TestPD_GetUser is a unit test for the GET "/user" method
Expand Down
48 changes: 24 additions & 24 deletions pkg/pd/response.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ type ResponseDownload struct {
type ResponseFileInfo struct {
ID string `json:"id"`
Name string `json:"name"`
Size int `json:"size"`
Views int `json:"views"`
BandwidthUsed int `json:"bandwidth_used"`
BandwidthUsedPaid int `json:"bandwidth_used_paid"`
Downloads int `json:"downloads"`
Size int64 `json:"size"`
Views int64 `json:"views"`
BandwidthUsed int64 `json:"bandwidth_used"`
BandwidthUsedPaid int64 `json:"bandwidth_used_paid"`
Downloads int64 `json:"downloads"`
DateUpload time.Time `json:"date_upload"`
DateLastView time.Time `json:"date_last_view"`
MimeType string `json:"mime_type"`
Expand Down Expand Up @@ -68,12 +68,12 @@ type FileGetList struct {
Success bool `json:"success"`
ID string `json:"id"`
Name string `json:"name"`
Size int `json:"size"`
Size int64 `json:"size"`
DateCreated time.Time `json:"date_created"`
DateLastView time.Time `json:"date_last_view"`
MimeType string `json:"mime_type"`
Views int `json:"views"`
BandwidthUsed int `json:"bandwidth_used"`
Views int64 `json:"views"`
BandwidthUsed int64 `json:"bandwidth_used"`
ThumbnailHref string `json:"thumbnail_href"`
}

Expand All @@ -89,12 +89,12 @@ type ResponseGetUser struct {
Username string `json:"username"`
Email string `json:"email"`
Subscription GetUserSubscription `json:"subscription"`
StorageSpaceUsed int `json:"storage_space_used"`
StorageSpaceUsed int64 `json:"storage_space_used"`
IsAdmin bool `json:"is_admin"`
BalanceMicroEur int `json:"balance_micro_eur"`
BalanceMicroEur int64 `json:"balance_micro_eur"`
HotlinkingEnabled bool `json:"hotlinking_enabled"`
MonthlyTransferCap int `json:"monthly_transfer_cap"`
MonthlyTransferUsed int `json:"monthly_transfer_used"`
MonthlyTransferCap int64 `json:"monthly_transfer_cap"`
MonthlyTransferUsed int64 `json:"monthly_transfer_used"`
FileViewerBranding interface{} `json:"file_viewer_branding"`
FileEmbedDomains string `json:"file_embed_domains"`
SkipFileViewer bool `json:"skip_file_viewer"`
Expand All @@ -106,22 +106,22 @@ type GetUserSubscription struct {
Name string `json:"name"`
Type string `json:"type"`
FileSizeLimit int64 `json:"file_size_limit"`
FileExpiryDays int `json:"file_expiry_days"`
StorageSpace int `json:"storage_space"`
PricePerTbStorage int `json:"price_per_tb_storage"`
PricePerTbBandwidth int `json:"price_per_tb_bandwidth"`
MonthlyTransferCap int `json:"monthly_transfer_cap"`
FileExpiryDays int64 `json:"file_expiry_days"`
StorageSpace int64 `json:"storage_space"`
PricePerTbStorage int64 `json:"price_per_tb_storage"`
PricePerTbBandwidth int64 `json:"price_per_tb_bandwidth"`
MonthlyTransferCap int64 `json:"monthly_transfer_cap"`
FileViewerBranding bool `json:"file_viewer_branding"`
}

type FileGetUser struct {
ID string `json:"id"`
Name string `json:"name"`
Size int `json:"size"`
Views int `json:"views"`
BandwidthUsed int `json:"bandwidth_used"`
BandwidthUsedPaid int `json:"bandwidth_used_paid"`
Downloads int `json:"downloads"`
Size int64 `json:"size"`
Views int64 `json:"views"`
BandwidthUsed int64 `json:"bandwidth_used"`
BandwidthUsedPaid int64 `json:"bandwidth_used_paid"`
Downloads int64 `json:"downloads"`
DateUpload time.Time `json:"date_upload"`
DateLastView time.Time `json:"date_last_view"`
MimeType string `json:"mime_type"`
Expand All @@ -134,7 +134,7 @@ type FileGetUser struct {
CanEdit bool `json:"can_edit"`
ShowAds bool `json:"show_ads"`
AllowVideoPlayer bool `json:"allow_video_player"`
DownloadSpeedLimit int `json:"download_speed_limit"`
DownloadSpeedLimit int64 `json:"download_speed_limit"`
}

type ResponseGetUserFiles struct {
Expand All @@ -146,7 +146,7 @@ type ListsGetUser struct {
ID string `json:"id"`
Title string `json:"title"`
DateCreated time.Time `json:"date_created"`
FileCount int `json:"file_count"`
FileCount int64 `json:"file_count"`
Files interface{} `json:"files"`
CanEdit bool `json:"can_edit"`
}
Expand Down

0 comments on commit abc5729

Please sign in to comment.