Skip to content
This repository has been archived by the owner on Jan 4, 2025. It is now read-only.

Commit

Permalink
fix test harness and switch to more consistent d.directory call
Browse files Browse the repository at this point in the history
  • Loading branch information
mrobinsn committed Dec 29, 2021
1 parent f6482be commit 2d0b8a2
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 28 deletions.
16 changes: 0 additions & 16 deletions .travis.yml

This file was deleted.

5 changes: 3 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ module github.com/mrobinsn/go-rtorrent
go 1.15

require (
github.com/pkg/errors v0.8.1
github.com/cpuguy83/go-md2man/v2 v2.0.1 // indirect
github.com/pkg/errors v0.9.1
github.com/stretchr/testify v1.3.0
github.com/urfave/cli v1.20.0
github.com/urfave/cli v1.22.5
)
18 changes: 14 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,11 +1,21 @@
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
github.com/cpuguy83/go-md2man/v2 v2.0.1 h1:r/myEWzV9lfsM1tFLgDyu0atFtJ1fXn261LKYj/3DxU=
github.com/cpuguy83/go-md2man/v2 v2.0.1/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I=
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk=
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/urfave/cli v1.20.0 h1:fDqGv3UG/4jbVl/QkFwEdddtEDjh/5Ov6X+0B/3bPaw=
github.com/urfave/cli v1.20.0/go.mod h1:70zkFmudgCuE/ngEzBv17Jvp/497gISqfk5gWijbERA=
github.com/urfave/cli v1.22.5 h1:lNq9sAHXK2qfdI8W+GRItjCEkI+2oR4d+MEHy1CKXoU=
github.com/urfave/cli v1.22.5/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
8 changes: 5 additions & 3 deletions rtorrent/rtorrent.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ const (
DHash Field = "d.hash"
// DBasePath represents the base path of a "Downloading Item"
DBasePath Field = "d.base_path"
// DDirectory represents the directory of a "Downloading Item"
DDirectory Field = "d.directory"
// DIsActive represents whether a "Downloading Item" is active or not
DIsActive Field = "d.is_active"
// DRatio represents the ratio of a "Downloading Item"
Expand Down Expand Up @@ -323,7 +325,7 @@ func (r *RTorrent) UpRate() (int, error) {

// GetTorrents returns all of the torrents reported by this RTorrent instance
func (r *RTorrent) GetTorrents(view View) ([]Torrent, error) {
args := []interface{}{"", string(view), DName.Query(), DSizeInBytes.Query(), DHash.Query(), DLabel.Query(), DBasePath.Query(), DIsActive.Query(), DComplete.Query(), DRatio.Query(), DCreationTime.Query(), DFinishedTime.Query(), DStartedTime.Query()}
args := []interface{}{"", string(view), DName.Query(), DSizeInBytes.Query(), DHash.Query(), DLabel.Query(), DDirectory.Query(), DIsActive.Query(), DComplete.Query(), DRatio.Query(), DCreationTime.Query(), DFinishedTime.Query(), DStartedTime.Query()}
results, err := r.xmlrpcClient.Call("d.multicall2", args...)
var torrents []Torrent
if err != nil {
Expand Down Expand Up @@ -372,9 +374,9 @@ func (r *RTorrent) GetTorrent(hash string) (Torrent, error) {
}
t.Label = results.([]interface{})[0].(string)
// Path
results, err = r.xmlrpcClient.Call("d.base_path", t.Hash)
results, err = r.xmlrpcClient.Call("d.directory", t.Hash)
if err != nil {
return t, errors.Wrap(err, "d.base_path XMLRPC call failed")
return t, errors.Wrap(err, "d.directory XMLRPC call failed")
}
t.Path = results.([]interface{})[0].(string)
// Completed
Expand Down
3 changes: 1 addition & 2 deletions rtorrent/rtorrent_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -218,8 +218,7 @@ func TestRTorrent(t *testing.T) {
require.Equal(t, "Fedora-i3-Live-x86_64-35", torrents[0].Name)
require.Equal(t, label.Value, torrents[0].Label)
require.Equal(t, 1437206706, torrents[0].Size)
//no path yet since the torrent is stopped
require.Equal(t, "", torrents[0].Path)
require.Equal(t, "/downloads/temp/Fedora-i3-Live-x86_64-35", torrents[0].Path)
require.False(t, torrents[0].Completed)

t.Run("get status", func(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
docker rm -f rutorrent
rm -rf tmp
mkdir tmp
docker run -d --name=rutorrent -v $(pwd)/tmp/data:/config -v $(pwd)/tmp/downloads:/downloads -e PGID=1000 -e PUID=1000 -p 80:80 -p 5000:5000 -p 51413:51413 -p 6881:6881/udp linuxserver/rutorrent
docker run -d --name=rutorrent -p 8080:8080 -p 8000:8000 crazymax/rtorrent-rutorrent:latest
sleep 60
go test -v -race ./...

0 comments on commit 2d0b8a2

Please sign in to comment.