ci-platforms / darwin amd64 smoke (push) Skipped
GitHub / linux amd64 native GitHub-hosted native CI: success
ci-platforms / windows amd64 smoke (push) Skipped
GitHub / windows amd64 native GitHub-hosted native CI: success
GitHub / darwin arm64 native GitHub-hosted native CI: success
GitHub / darwin amd64 native GitHub-hosted native CI: success
ci / checks (push) Failing after 1h21m34s
ci / native-authoring (push) Skipped
ci-platforms / darwin arm64 smoke (push) Skipped
github-native / gitea-pending (push) Skipped
github-native / darwin amd64 native (push) Skipped
github-native / linux amd64 native (push) Skipped
github-native / windows amd64 native (push) Skipped
github-native / darwin arm64 native (push) Skipped
github-native / gitea-result (push) Skipped
ci / build (amd64, linux, ubuntu-24.04) (push) Successful in 12m4s
ci / release (push) Skipped
Add dockable Art tools, animation and previews, guarded asset workflows, and the Web Asset Studio built on the shared Art Core. Expand English and Russian documentation, interactive Try scenes, examples and editor icons. Add audio waveform navigation, source analysis, guarded previews and a browser Worker mixer. Preserve source changes and recovery with bounded checks, and strengthen native, browser and interoperability CI. Prepare version 0.12.5 and manually built native artifact candidates. Fix the production site image demo build dependency. Reuse immutable scene indices when capturing keyframes. Wait for real Persist save/load completion in component tests. Stabilize browser Game View captures outside pointer hover. Aseprite interchange and persistent Audio EDL recovery remain limited; the artifact workflow does not publish releases or change stable.
98 lines
3.0 KiB
Go
98 lines
3.0 KiB
Go
package update
|
|
|
|
import (
|
|
"context"
|
|
"errors"
|
|
"fmt"
|
|
"io"
|
|
"net"
|
|
"net/http"
|
|
"strings"
|
|
"syscall"
|
|
"testing"
|
|
)
|
|
|
|
type legacyTemporaryError struct{}
|
|
|
|
func (legacyTemporaryError) Error() string { return "legacy temporary error" }
|
|
func (legacyTemporaryError) Timeout() bool { return false }
|
|
func (legacyTemporaryError) Temporary() bool { return true }
|
|
|
|
type timeoutOnlyError struct{}
|
|
|
|
func (timeoutOnlyError) Error() string { return "timeout" }
|
|
func (timeoutOnlyError) Timeout() bool { return true }
|
|
|
|
func TestTransientCheckErrorExplicitReasons(t *testing.T) {
|
|
for _, tc := range []struct {
|
|
name string
|
|
err error
|
|
want bool
|
|
}{
|
|
{"nil", nil, false},
|
|
{"deadline", context.DeadlineExceeded, true},
|
|
{"wrapped timeout", fmt.Errorf("request: %w", timeoutOnlyError{}), true},
|
|
{"incomplete response", io.ErrUnexpectedEOF, true},
|
|
{"wrapped reset", &net.OpError{Op: "read", Err: syscall.ECONNRESET}, true},
|
|
{"connection refused", syscall.ECONNREFUSED, true},
|
|
{"connection aborted", syscall.ECONNABORTED, true},
|
|
{"try again", syscall.EAGAIN, true},
|
|
{"interrupted", syscall.EINTR, true},
|
|
{"DNS timeout", &net.DNSError{IsTimeout: true}, true},
|
|
{"temporary DNS", fmt.Errorf("lookup: %w", &net.DNSError{IsTemporary: true}), true},
|
|
{"DNS not found", &net.DNSError{IsNotFound: true}, false},
|
|
{"cancelled", context.Canceled, false},
|
|
{"wrapped cancellation", fmt.Errorf("request: %w", context.Canceled), false},
|
|
{"ordinary error", errors.New("bad response"), false},
|
|
{"unspecified legacy temporary", legacyTemporaryError{}, false},
|
|
} {
|
|
t.Run(tc.name, func(t *testing.T) {
|
|
if got := transientCheckError(tc.err); got != tc.want {
|
|
t.Fatalf("transientCheckError(%v) = %v, want %v", tc.err, got, tc.want)
|
|
}
|
|
})
|
|
}
|
|
}
|
|
|
|
type errorThenSuccessTransport struct {
|
|
err error
|
|
calls int
|
|
}
|
|
|
|
func (t *errorThenSuccessTransport) RoundTrip(req *http.Request) (*http.Response, error) {
|
|
t.calls++
|
|
if t.calls == 1 {
|
|
return nil, t.err
|
|
}
|
|
return &http.Response{StatusCode: http.StatusOK, Header: make(http.Header), Body: io.NopCloser(strings.NewReader("ok")), Request: req}, nil
|
|
}
|
|
|
|
func TestGetRetriesOnlyExplicitNetworkFailures(t *testing.T) {
|
|
for _, tc := range []struct {
|
|
name string
|
|
err error
|
|
wantCalls int
|
|
}{
|
|
{"temporary DNS", &net.DNSError{IsTemporary: true}, 2},
|
|
{"connection reset", syscall.ECONNRESET, 2},
|
|
{"unspecified legacy temporary", legacyTemporaryError{}, 1},
|
|
{"cancelled", context.Canceled, 1},
|
|
} {
|
|
t.Run(tc.name, func(t *testing.T) {
|
|
transport := &errorThenSuccessTransport{err: tc.err}
|
|
source := &Source{Client: &http.Client{Transport: transport}}
|
|
data, _, err := source.get(context.Background(), "https://example.invalid/release.json", "")
|
|
if transport.calls != tc.wantCalls {
|
|
t.Fatalf("made %d requests, want %d", transport.calls, tc.wantCalls)
|
|
}
|
|
if tc.wantCalls == 1 {
|
|
if err == nil {
|
|
t.Fatal("non-retryable error was accepted")
|
|
}
|
|
} else if err != nil || string(data) != "ok" {
|
|
t.Fatalf("retry result: %q, %v", data, err)
|
|
}
|
|
})
|
|
}
|
|
}
|