Restore the server() test helper that the v1.1.7 tag left out. The tag carries api/api_authentication_test.go, which calls server(), but not api/helpers_test.go, where upstream main defines it: https://github.com/PlakarKorp/plakar/commit/1402c42194e55d0b8f1ba49513ac30980838d402 Only server() is taken from main. Drop this patch when the release branch carries it. --- /dev/null +++ b/api/helpers_test.go @@ -0,0 +1,32 @@ +package api + +import ( + "bytes" + "net/http" + "testing" + + "github.com/PlakarKorp/kloset/repository" + "github.com/PlakarKorp/kloset/snapshot" + "github.com/PlakarKorp/plakar/appcontext" + ptesting "github.com/PlakarKorp/plakar/testing" +) + +// server builds a real repository with a richer snapshot than newAPIServer +// (nested dirs, multiple files) and wires SetupRoutes with norefresh=true. +// Distinct name to avoid clashing with the team's newAPIServer helper. +func server(t *testing.T, token string) (*http.ServeMux, *repository.Repository, *snapshot.Snapshot, *appcontext.AppContext) { + t.Helper() + repo, ctx := ptesting.GenerateRepository(t, bytes.NewBuffer(nil), bytes.NewBuffer(nil), nil) + snap := ptesting.GenerateSnapshot(t, repo, []ptesting.MockFile{ + ptesting.NewMockDir("subdir"), + ptesting.NewMockFile("subdir/dummy.txt", 0644, "hello dummy"), + ptesting.NewMockFile("subdir/foo.txt", 0644, "hello foo"), + ptesting.NewMockFile("subdir/noext", 0644, "hello noext"), + ptesting.NewMockDir("subdir/nested"), + ptesting.NewMockFile("subdir/nested/deep.txt", 0644, "deep content"), + ptesting.NewMockFile("top.txt", 0644, "top level"), + }) + mux := http.NewServeMux() + SetupRoutes(mux, repo, ctx, token, true /* norefresh */) + return mux, repo, snap, ctx +}