-
-
Notifications
You must be signed in to change notification settings - Fork 139
feat(qbittorrent): show process uptime #1849
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
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
debf25c
feat(qbittorrent): show process uptime
s0up4200 44a7ad4
chore(qbittorrent): keep existing client dependency
s0up4200 b864511
Merge branch 'develop' into feat/qbittorrent-process-uptime
s0up4200 16991ae
chore(deps): bump go-qbittorrent to 4580a4c
s0up4200 7985c6f
fix(qbittorrent): pin login recursion fix
s0up4200 581c48c
test(qbittorrent): table drive process info coverage
s0up4200 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,104 @@ | ||
| package handlers | ||
|
|
||
| import ( | ||
| "context" | ||
| "errors" | ||
| "testing" | ||
|
|
||
| qbt "github.com/autobrr/go-qbittorrent" | ||
| "github.com/stretchr/testify/require" | ||
| ) | ||
|
|
||
| type stubQBittorrentAppInfoClient struct { | ||
| version string | ||
| webAPIVersion string | ||
| buildInfo qbt.BuildInfo | ||
| processInfo qbt.ProcessInfo | ||
| processInfoCalled bool | ||
| processInfoCallErr error | ||
| } | ||
|
|
||
| func (c *stubQBittorrentAppInfoClient) GetAppVersionCtx(context.Context) (string, error) { | ||
| return c.version, nil | ||
| } | ||
|
|
||
| func (c *stubQBittorrentAppInfoClient) GetWebAPIVersionCtx(context.Context) (string, error) { | ||
| return c.webAPIVersion, nil | ||
| } | ||
|
|
||
| func (c *stubQBittorrentAppInfoClient) GetBuildInfoCtx(context.Context) (qbt.BuildInfo, error) { | ||
| return c.buildInfo, nil | ||
| } | ||
|
|
||
| func (c *stubQBittorrentAppInfoClient) GetProcessInfoCtx(context.Context) (qbt.ProcessInfo, error) { | ||
| c.processInfoCalled = true | ||
| return c.processInfo, c.processInfoCallErr | ||
| } | ||
|
|
||
| func TestGetQBittorrentAppInfoProcessInfo(t *testing.T) { | ||
| processInfoErr := errors.New("process info unavailable") | ||
|
|
||
| tests := []struct { | ||
| name string | ||
| version string | ||
| webAPIVersion string | ||
| processInfo qbt.ProcessInfo | ||
| processInfoErr error | ||
| wantProcessInfoCalled bool | ||
| wantLaunchTime int64 | ||
| wantProcessInfo bool | ||
| }{ | ||
| { | ||
| name: "includes process info for supported web api", | ||
| version: "v5.2.0", | ||
| webAPIVersion: "2.15.1", | ||
| processInfo: qbt.ProcessInfo{LaunchTime: 1769331513}, | ||
| wantProcessInfoCalled: true, | ||
| wantLaunchTime: 1769331513, | ||
| wantProcessInfo: true, | ||
| }, | ||
| { | ||
| name: "skips process info for older web api", | ||
| version: "v5.1.4", | ||
| webAPIVersion: "2.11.4", | ||
| processInfo: qbt.ProcessInfo{LaunchTime: 1769331513}, | ||
| wantProcessInfoCalled: false, | ||
| wantProcessInfo: false, | ||
| }, | ||
| { | ||
| name: "omits process info when supported call fails", | ||
| version: "v5.2.0", | ||
| webAPIVersion: "2.15.1", | ||
| processInfoErr: processInfoErr, | ||
| wantProcessInfoCalled: true, | ||
| wantProcessInfo: false, | ||
| }, | ||
| } | ||
|
|
||
| for _, tt := range tests { | ||
| t.Run(tt.name, func(t *testing.T) { | ||
| client := &stubQBittorrentAppInfoClient{ | ||
| version: tt.version, | ||
| webAPIVersion: tt.webAPIVersion, | ||
| buildInfo: qbt.BuildInfo{ | ||
| Libtorrent: "2.0.11", | ||
| Platform: "linux", | ||
| }, | ||
| processInfo: tt.processInfo, | ||
| processInfoCallErr: tt.processInfoErr, | ||
| } | ||
|
|
||
| info, err := getQBittorrentAppInfo(context.Background(), client) | ||
|
|
||
| require.NoError(t, err) | ||
| require.Equal(t, tt.wantProcessInfoCalled, client.processInfoCalled) | ||
| if !tt.wantProcessInfo { | ||
| require.Nil(t, info.ProcessInfo) | ||
| return | ||
| } | ||
|
|
||
| require.NotNil(t, info.ProcessInfo) | ||
| require.Equal(t, tt.wantLaunchTime, info.ProcessInfo.LaunchTime) | ||
| }) | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.