mirror of
https://github.com/samuelncui/acp.git
synced 2026-09-25 16:54:14 +00:00
fix: harden signature cache publication
This commit is contained in:
+39
@@ -1,8 +1,10 @@
|
||||
package acp
|
||||
|
||||
import (
|
||||
"context"
|
||||
"path/filepath"
|
||||
"sort"
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
@@ -98,3 +100,40 @@ func TestLinearDeviceOnlySerializesItsOwnStage(t *testing.T) {
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestNewRejectsNegativeDeviceThreads(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
option Option
|
||||
want string
|
||||
}{
|
||||
{
|
||||
name: "source",
|
||||
option: SetFromDevice(DeviceThreads(-1)),
|
||||
want: "check source device failed",
|
||||
},
|
||||
{
|
||||
name: "target",
|
||||
option: SetToDevice(DeviceThreads(-1)),
|
||||
want: "check target device failed",
|
||||
},
|
||||
{
|
||||
name: "linear source",
|
||||
option: SetFromDevice(DeviceThreads(-1), LinearDevice(true)),
|
||||
want: "check source device failed",
|
||||
},
|
||||
}
|
||||
|
||||
for _, test := range tests {
|
||||
t.Run(test.name, func(t *testing.T) {
|
||||
copyer, err := New(context.Background(), test.option)
|
||||
if err == nil {
|
||||
copyer.Wait()
|
||||
t.Fatal("New() error = nil")
|
||||
}
|
||||
if !strings.Contains(err.Error(), test.want) || !strings.Contains(err.Error(), "threads=-1") {
|
||||
t.Fatalf("New() error = %q, want %q and thread count", err, test.want)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user