Request budgets, measured against the fake server and asserted at the measured counts, for listing (cold and warm, with and without enable_caching), a no-op sync by modification time and by checksum, NewObject three folders deep, uploads and making folders. A TestMain hook fails the package if any test, through any fake server, requested a removed share-scoped route; the fake keeps a process-wide tally of them for it. Fuzz targets, seeded from testdata/oldlib and from what the fake writes, for name validation, link decoding, extended attributes, API error bodies with Retry-After and session fork payloads. Each checks invariants of what is accepted. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
34 lines
1.0 KiB
Go
34 lines
1.0 KiB
Go
package protondrive
|
|
|
|
import (
|
|
"context"
|
|
"testing"
|
|
|
|
"github.com/rclone/rclone/backend/protondrive/protontest"
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
// newTestClient returns a client with caching enabled for a new user
|
|
// of a new fake server, signed in without a login round trip.
|
|
func newTestClient(t testing.TB) (*client, *protontest.Server, *protontest.User) {
|
|
t.Helper()
|
|
return newTestClientOpt(t, clientOptions{EnableCaching: true})
|
|
}
|
|
|
|
// newTestClientOpt is newTestClient with the options opt.
|
|
func newTestClientOpt(t testing.TB, opt clientOptions) (*client, *protontest.Server, *protontest.User) {
|
|
t.Helper()
|
|
srv := protontest.New(t)
|
|
u := srv.AddUser("user", "pass")
|
|
return newTestClientFor(t, srv, u, opt), srv, u
|
|
}
|
|
|
|
// newTestClientFor returns a client for a new session of u.
|
|
func newTestClientFor(t testing.TB, srv *protontest.Server, u *protontest.User, opt clientOptions) *client {
|
|
t.Helper()
|
|
c, err := newClient(context.Background(), newAccountSession(srv, u), opt)
|
|
require.NoError(t, err)
|
|
t.Cleanup(c.close)
|
|
return c
|
|
}
|