test: RunOnListener, local pypi virtual merge, v2 download, waitForStore/Unwrap
This commit is contained in:
@@ -318,6 +318,47 @@ func TestBearerTokenParsing(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestWaitForStoreCoalesces(t *testing.T) {
|
||||
requireStack(t)
|
||||
ctx := context.Background()
|
||||
r := seed(t, genericRemote("eng-herd"))
|
||||
p := prov(t, models.PackageGeneric)
|
||||
|
||||
// Fire concurrent cold-cache fetches: only one holds the lock, the others
|
||||
// wait on the store (waitForStore) and pick up the result.
|
||||
const n = 4
|
||||
done := make(chan string, n)
|
||||
for i := 0; i < n; i++ {
|
||||
go func() {
|
||||
res, err := testEngine.Fetch(ctx, r, "blob.bin", p)
|
||||
if err != nil {
|
||||
done <- "err:" + err.Error()
|
||||
return
|
||||
}
|
||||
done <- readAll(t, res)
|
||||
}()
|
||||
}
|
||||
for i := 0; i < n; i++ {
|
||||
if got := <-done; got != "immutable blob" {
|
||||
t.Errorf("concurrent fetch got %q", got)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestUpstreamErrorUnwrap(t *testing.T) {
|
||||
base := context.DeadlineExceeded
|
||||
ue := &UpstreamError{Err: base}
|
||||
if ue.Unwrap() != base {
|
||||
t.Error("Unwrap should return the wrapped error")
|
||||
}
|
||||
if !isNetworkError(ue) {
|
||||
t.Error("UpstreamError should be a network error")
|
||||
}
|
||||
if isNetworkError(context.Canceled) {
|
||||
t.Error("plain error should not be a network error")
|
||||
}
|
||||
}
|
||||
|
||||
func asProxyError(err error, target **ProxyError) bool {
|
||||
pe, ok := err.(*ProxyError)
|
||||
if ok {
|
||||
|
||||
Reference in New Issue
Block a user