downloader

package
v0.0.0-...-2686f8f Latest Latest
Warning

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

Go to latest
Published: Aug 13, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Downloader

type Downloader interface {
	Download(c cache.Cache, l provider.Provider, tiles ...tile.Tile) ([]tile.Tile, error)
	Merge(side int, centerTile tile.Tile, tiles ...tile.Tile) ([]byte, error)
}

Downloader implements basic downloader interface

type DownloaderMock

type DownloaderMock struct {
	// DownloadFunc mocks the Download method.
	DownloadFunc func(c cache.Cache, l provider.Provider, tiles ...tile.Tile) ([]tile.Tile, error)

	// MergeFunc mocks the Merge method.
	MergeFunc func(side int, centerTile tile.Tile, tiles ...tile.Tile) ([]byte, error)
	// contains filtered or unexported fields
}

DownloaderMock is a mock implementation of Downloader.

func TestSomethingThatUsesDownloader(t *testing.T) {

	// make and configure a mocked Downloader
	mockedDownloader := &DownloaderMock{
		DownloadFunc: func(c cache.Cache, l provider.Provider, tiles ...tile.Tile) ([]tile.Tile, error) {
			panic("mock out the Download method")
		},
		MergeFunc: func(side int, centerTile tile.Tile, tiles ...tile.Tile) ([]byte, error) {
			panic("mock out the Merge method")
		},
	}

	// use mockedDownloader in code that requires Downloader
	// and then make assertions.

}

func (*DownloaderMock) Download

func (mock *DownloaderMock) Download(c cache.Cache, l provider.Provider, tiles ...tile.Tile) ([]tile.Tile, error)

Download calls DownloadFunc.

func (*DownloaderMock) DownloadCalls

func (mock *DownloaderMock) DownloadCalls() []struct {
	C     cache.Cache
	L     provider.Provider
	Tiles []tile.Tile
}

DownloadCalls gets all the calls that were made to Download. Check the length with:

len(mockedDownloader.DownloadCalls())

func (*DownloaderMock) Merge

func (mock *DownloaderMock) Merge(side int, centerTile tile.Tile, tiles ...tile.Tile) ([]byte, error)

Merge calls MergeFunc.

func (*DownloaderMock) MergeCalls

func (mock *DownloaderMock) MergeCalls() []struct {
	Side       int
	CenterTile tile.Tile
	Tiles      []tile.Tile
}

MergeCalls gets all the calls that were made to Merge. Check the length with:

len(mockedDownloader.MergeCalls())

type MapDownloader

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

MapDownloader implements interface Downloader

func NewMapDownloader

func NewMapDownloader(client *http.Client) *MapDownloader

NewMapDownloader create new MapDownloader with specified httpClient

func (*MapDownloader) Download

func (m *MapDownloader) Download(c cache.Cache, l provider.Provider, tiles ...tile.Tile) ([]tile.Tile, error)

Download orchestrates the concurrent downloading of multiple tiles using a specified provider

func (*MapDownloader) Merge

func (m *MapDownloader) Merge(side int, centerTile tile.Tile, tiles ...tile.Tile) ([]byte, error)

Merge combines multiple tiles into a single image.

Jump to

Keyboard shortcuts

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