Copyright 2019 The Go Authors. All rights reserved. Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.

package index

import (
	
	
	
	

	
	
)
SetupTestIndex creates a module index for testing using the given version map for data. It returns a function for tearing down the index server after the test is completed, and a Client for interacting with the test index.
func ( *testing.T,  []*internal.IndexVersion) (*Client, func()) {
	.Helper()

	, ,  := testhelper.SetupTestClientAndServer(
		http.HandlerFunc(func( http.ResponseWriter,  *http.Request) {
			 := len()
			if  := .FormValue("limit");  != "" {
				var  error
				,  = strconv.Atoi()
				if  != nil {
					.Fatalf("error parsing limit parameter: %v", )
				}
			}
			.Header().Set("Content-Type", "application/json")
			for  := 0;  <  &&  < len(); ++ {
				json.NewEncoder().Encode([])
			}
		}))

	,  := New(.URL)
	if  != nil {
		.Fatal()
	}
	.httpClient = 

	 := func() {
		()
	}
	return ,