testloader

package
v0.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 1, 2021 License: Apache-2.0, MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FakeAsyncLoader

type FakeAsyncLoader struct {
	// contains filtered or unexported fields
}

FakeAsyncLoader simultates the requestmanager.AsyncLoader interface with mocked responses and can also be used to simulate a executor.AsycLoadFn -- all responses are stubbed and no actual processing is done

func NewFakeAsyncLoader

func NewFakeAsyncLoader() *FakeAsyncLoader

NewFakeAsyncLoader returns a new FakeAsyncLoader instance

func (*FakeAsyncLoader) AsyncLoad

func (fal *FakeAsyncLoader) AsyncLoad(requestID graphsync.RequestID, link ld.Link) <-chan types.AsyncLoadResult

AsyncLoad simulates an asynchronous load with responses stubbed by ResponseOn & SuccessResponseOn

func (*FakeAsyncLoader) CleanupRequest

func (fal *FakeAsyncLoader) CleanupRequest(requestID graphsync.RequestID)

CleanupRequest simulates the effect of cleaning up the request by removing any response channels for the request

func (*FakeAsyncLoader) CompleteResponsesFor

func (fal *FakeAsyncLoader) CompleteResponsesFor(requestID graphsync.RequestID)

CompleteResponsesFor in the case of the test loader does nothing

func (*FakeAsyncLoader) OnAsyncLoad

func (fal *FakeAsyncLoader) OnAsyncLoad(cb func(graphsync.RequestID, ld.Link, <-chan types.AsyncLoadResult))

OnAsyncLoad allows you to listen for load requests to the loader and perform other actions or tests

func (*FakeAsyncLoader) ProcessResponse

func (fal *FakeAsyncLoader) ProcessResponse(responses map[graphsync.RequestID]metadata.Metadata,
	blks []blocks.Block)

ProcessResponse just records values passed to verify expectations later

func (*FakeAsyncLoader) ResponseOn

func (fal *FakeAsyncLoader) ResponseOn(requestID graphsync.RequestID, link ld.Link, result types.AsyncLoadResult)

ResponseOn sets the value returned when the given link is loaded for the given request. Because it's an "asynchronous" load, this can be called AFTER the attempt to load this link -- and the client will only get the response at that point

func (*FakeAsyncLoader) StartRequest

func (fal *FakeAsyncLoader) StartRequest(requestID graphsync.RequestID, name string) error

StartRequest just requests what store was requested for a given requestID

func (*FakeAsyncLoader) SuccessResponseOn

func (fal *FakeAsyncLoader) SuccessResponseOn(requestID graphsync.RequestID, blks []blocks.Block)

SuccessResponseOn is convenience function for setting several asynchronous responses at once as all successes and returning the given blocks

func (*FakeAsyncLoader) VerifyLastProcessedBlocks

func (fal *FakeAsyncLoader) VerifyLastProcessedBlocks(ctx context.Context, t *testing.T, expectedBlocks []blocks.Block)

VerifyLastProcessedBlocks verifies the blocks passed to the last call to ProcessResponse match the expected ones

func (*FakeAsyncLoader) VerifyLastProcessedResponses

func (fal *FakeAsyncLoader) VerifyLastProcessedResponses(ctx context.Context, t *testing.T,
	expectedResponses map[graphsync.RequestID]metadata.Metadata)

VerifyLastProcessedResponses verifies the responses passed to the last call to ProcessResponse match the expected ones

func (*FakeAsyncLoader) VerifyNoRemainingData

func (fal *FakeAsyncLoader) VerifyNoRemainingData(t *testing.T, requestID graphsync.RequestID)

VerifyNoRemainingData verifies no outstanding response channels are open for the given RequestID (CleanupRequest was called last)

func (*FakeAsyncLoader) VerifyStoreUsed

func (fal *FakeAsyncLoader) VerifyStoreUsed(t *testing.T, requestID graphsync.RequestID, storeName string)

VerifyStoreUsed verifies the given store was used for the given request

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL