fix(ci): fix lint errors and pin CI to Go 1.25
- Run gofmt on all files - Export SetupUPnP to fix unused lint error - Remove Go 1.26 from CI matrix (only test with 1.25)
This commit is contained in:
parent
3e0f3a5a64
commit
d0dbfc3d12
10 changed files with 31 additions and 31 deletions
2
.github/workflows/ci.yml
vendored
2
.github/workflows/ci.yml
vendored
|
|
@ -15,7 +15,7 @@ jobs:
|
|||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
matrix:
|
||||
go-version: ["1.25", "1.26"]
|
||||
go-version: ["1.25"]
|
||||
steps:
|
||||
- uses: actions/checkout@v6
|
||||
|
||||
|
|
|
|||
|
|
@ -531,7 +531,7 @@ func TestBatchDownload(t *testing.T) {
|
|||
t.Errorf("path = %s", r.URL.Path)
|
||||
}
|
||||
json.NewEncoder(w).Encode(BatchDownloadResponse{
|
||||
Queued: 3,
|
||||
Queued: 3,
|
||||
NotFound: 1,
|
||||
})
|
||||
}))
|
||||
|
|
|
|||
|
|
@ -9,8 +9,8 @@ func TestDeriveWSURL(t *testing.T) {
|
|||
want string
|
||||
}{
|
||||
{"https://torrentclaw.com", "agent-123", "wss://unarr.torrentclaw.com/ws/agent-123"},
|
||||
{"http://localhost:3000", "a1", ""}, // localhost skipped
|
||||
{"http://127.0.0.1:3000", "a1", ""}, // 127.0.0.1 skipped
|
||||
{"http://localhost:3000", "a1", ""}, // localhost skipped
|
||||
{"http://127.0.0.1:3000", "a1", ""}, // 127.0.0.1 skipped
|
||||
{"https://torrentclaw.com/", "a1", "wss://unarr.torrentclaw.com/ws/a1"},
|
||||
{"https://api.example.io", "x", "wss://unarr.api.example.io/ws/x"},
|
||||
{"", "agent-123", ""},
|
||||
|
|
|
|||
|
|
@ -301,6 +301,6 @@ func (m *slowMockDownloader) Download(ctx context.Context, _ *Task, _ string, _
|
|||
<-ctx.Done()
|
||||
return nil, ctx.Err()
|
||||
}
|
||||
func (m *slowMockDownloader) Pause(_ string) error { return nil }
|
||||
func (m *slowMockDownloader) Cancel(_ string) error { return nil }
|
||||
func (m *slowMockDownloader) Pause(_ string) error { return nil }
|
||||
func (m *slowMockDownloader) Cancel(_ string) error { return nil }
|
||||
func (m *slowMockDownloader) Shutdown(_ context.Context) error { return nil }
|
||||
|
|
|
|||
|
|
@ -41,10 +41,10 @@ type ProgressReporter struct {
|
|||
onStreamRequested ActionFunc
|
||||
onWatchingChanged func(watching bool)
|
||||
|
||||
mu sync.Mutex
|
||||
latest map[string]*Task // taskID -> task with latest progress
|
||||
lastReported map[string]TaskStatus // taskID -> last status sent to API
|
||||
lastCheckAt time.Time // last time we reported for control-signal polling
|
||||
mu sync.Mutex
|
||||
latest map[string]*Task // taskID -> task with latest progress
|
||||
lastReported map[string]TaskStatus // taskID -> last status sent to API
|
||||
lastCheckAt time.Time // last time we reported for control-signal polling
|
||||
}
|
||||
|
||||
// NewProgressReporter creates a reporter that flushes every interval.
|
||||
|
|
|
|||
|
|
@ -230,10 +230,10 @@ func TestProgressReporter_HandleResponseDeleteFiles(t *testing.T) {
|
|||
|
||||
var deletedID string
|
||||
pr := &ProgressReporter{
|
||||
reporter: reporter,
|
||||
interval: time.Second,
|
||||
latest: make(map[string]*Task),
|
||||
lastReported: make(map[string]TaskStatus),
|
||||
reporter: reporter,
|
||||
interval: time.Second,
|
||||
latest: make(map[string]*Task),
|
||||
lastReported: make(map[string]TaskStatus),
|
||||
onDeleteFiles: func(id string) { deletedID = id },
|
||||
}
|
||||
|
||||
|
|
@ -254,10 +254,10 @@ func TestProgressReporter_HandleResponseStream(t *testing.T) {
|
|||
|
||||
var streamID string
|
||||
pr := &ProgressReporter{
|
||||
reporter: reporter,
|
||||
interval: time.Second,
|
||||
latest: make(map[string]*Task),
|
||||
lastReported: make(map[string]TaskStatus),
|
||||
reporter: reporter,
|
||||
interval: time.Second,
|
||||
latest: make(map[string]*Task),
|
||||
lastReported: make(map[string]TaskStatus),
|
||||
onStreamRequested: func(id string) { streamID = id },
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -17,9 +17,9 @@ type UPnPMapping struct {
|
|||
device upnp.Device
|
||||
}
|
||||
|
||||
// setupUPnP discovers the gateway, maps the port, and gets the public IP.
|
||||
// SetupUPnP discovers the gateway, maps the port, and gets the public IP.
|
||||
// Returns nil if UPnP is not available or fails.
|
||||
func setupUPnP(internalPort int) (*UPnPMapping, error) {
|
||||
func SetupUPnP(internalPort int) (*UPnPMapping, error) {
|
||||
log.Println("stream: discovering UPnP gateway (10s timeout)...")
|
||||
devices := upnp.Discover(0, 10*time.Second, alog.Logger{})
|
||||
if len(devices) == 0 {
|
||||
|
|
|
|||
|
|
@ -275,7 +275,7 @@ func TestFormatTimeAgo(t *testing.T) {
|
|||
now := time.Now()
|
||||
|
||||
tests := []struct {
|
||||
name string
|
||||
name string
|
||||
input string
|
||||
want string
|
||||
}{
|
||||
|
|
@ -356,6 +356,6 @@ func TestPtr(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func ptr[T any](v T) *T { return &v }
|
||||
func intPtr(v int) *int { return &v }
|
||||
func ptr[T any](v T) *T { return &v }
|
||||
func intPtr(v int) *int { return &v }
|
||||
func strPtr(v string) *string { return &v }
|
||||
|
|
|
|||
|
|
@ -753,9 +753,9 @@ func TestIsSampleFile(t *testing.T) {
|
|||
{"movie-sample-video.mkv", true},
|
||||
{"movie_sample.mkv", true},
|
||||
{"sample.mkv", true},
|
||||
{"resampled.mkv", false}, // "sample" is part of "resampled"
|
||||
{"resampled.mkv", false}, // "sample" is part of "resampled"
|
||||
{"movie.mkv", false},
|
||||
{"my.samples.zip", false}, // "sample" followed by 's' (alphanumeric)
|
||||
{"my.samples.zip", false}, // "sample" followed by 's' (alphanumeric)
|
||||
}
|
||||
for _, tt := range tests {
|
||||
if got := isSampleFile(tt.name); got != tt.want {
|
||||
|
|
@ -880,15 +880,15 @@ func TestIsRarFile_Extended(t *testing.T) {
|
|||
name string
|
||||
want bool
|
||||
}{
|
||||
{"file.RAR", true}, // case insensitive
|
||||
{"file.RAR", true}, // case insensitive
|
||||
{"file.Rar", true},
|
||||
{"file.s01", true},
|
||||
{"file.s99", true},
|
||||
{"file.002", true},
|
||||
{"file.999", true},
|
||||
{"file.r0", false}, // too short extension
|
||||
{"file.rXX", false}, // non-numeric
|
||||
{"file", false}, // no extension
|
||||
{"file.r0", false}, // too short extension
|
||||
{"file.rXX", false}, // non-numeric
|
||||
{"file", false}, // no extension
|
||||
{"file.mp4", false},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
|
|
|
|||
|
|
@ -14,12 +14,12 @@ func TestFindPar2File(t *testing.T) {
|
|||
vol1 := filepath.Join(dir, "content.vol000+01.par2")
|
||||
vol2 := filepath.Join(dir, "content.vol001+02.par2")
|
||||
|
||||
os.WriteFile(mainPar2, make([]byte, 100), 0o644) // smallest
|
||||
os.WriteFile(mainPar2, make([]byte, 100), 0o644) // smallest
|
||||
os.WriteFile(vol1, make([]byte, 10000), 0o644)
|
||||
os.WriteFile(vol2, make([]byte, 50000), 0o644)
|
||||
|
||||
files := map[string]string{
|
||||
"content.par2": mainPar2,
|
||||
"content.par2": mainPar2,
|
||||
"content.vol000+01.par2": vol1,
|
||||
"content.vol001+02.par2": vol2,
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue