client

package
v2.5.3 Latest Latest
Warning

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

Go to latest
Published: Sep 26, 2024 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cipher

type Cipher interface {
	Encrypt(plainTextFile, cipherTextFile string) error
	Decrypt(cipherTextFile, plainTextFile string) error
}

type CipherStub

type CipherStub struct {
	// DecryptFunc mocks the Decrypt method.
	DecryptFunc func(cipherTextFile string, plainTextFile string) error

	// EncryptFunc mocks the Encrypt method.
	EncryptFunc func(plainTextFile string, cipherTextFile string) error
	// contains filtered or unexported fields
}

CipherStub is a mock implementation of Cipher.

func TestSomethingThatUsesCipher(t *testing.T) {

	// make and configure a mocked Cipher
	mockedCipher := &CipherStub{
		DecryptFunc: func(cipherTextFile string, plainTextFile string) error {
			panic("mock out the Decrypt method")
		},
		EncryptFunc: func(plainTextFile string, cipherTextFile string) error {
			panic("mock out the Encrypt method")
		},
	}

	// use mockedCipher in code that requires Cipher
	// and then make assertions.

}

func (*CipherStub) Decrypt

func (mock *CipherStub) Decrypt(cipherTextFile string, plainTextFile string) error

Decrypt calls DecryptFunc.

func (*CipherStub) DecryptCalls

func (mock *CipherStub) DecryptCalls() []struct {
	CipherTextFile string
	PlainTextFile  string
}

DecryptCalls gets all the calls that were made to Decrypt. Check the length with:

len(mockedCipher.DecryptCalls())

func (*CipherStub) Encrypt

func (mock *CipherStub) Encrypt(plainTextFile string, cipherTextFile string) error

Encrypt calls EncryptFunc.

func (*CipherStub) EncryptCalls

func (mock *CipherStub) EncryptCalls() []struct {
	PlainTextFile  string
	CipherTextFile string
}

EncryptCalls gets all the calls that were made to Encrypt. Check the length with:

len(mockedCipher.EncryptCalls())

type Client

type Client struct {
	Hash   Hash
	Cipher Cipher
	Store  Store
}

func (*Client) GetRemoteFile

func (c *Client) GetRemoteFile(remotePath, localPath string) error

func (*Client) PutLocalFile

func (c *Client) PutLocalFile(remotePath, localPath string) error

type Hash

type Hash interface {
	Calculate(filePath string) (string, error)
	Verify(filePath, expectedChecksum string) error
}

type HashStub

type HashStub struct {
	// CalculateFunc mocks the Calculate method.
	CalculateFunc func(filePath string) (string, error)

	// VerifyFunc mocks the Verify method.
	VerifyFunc func(filePath string, expectedChecksum string) error
	// contains filtered or unexported fields
}

HashStub is a mock implementation of Hash.

func TestSomethingThatUsesHash(t *testing.T) {

	// make and configure a mocked Hash
	mockedHash := &HashStub{
		CalculateFunc: func(filePath string) (string, error) {
			panic("mock out the Calculate method")
		},
		VerifyFunc: func(filePath string, expectedChecksum string) error {
			panic("mock out the Verify method")
		},
	}

	// use mockedHash in code that requires Hash
	// and then make assertions.

}

func (*HashStub) Calculate

func (mock *HashStub) Calculate(filePath string) (string, error)

Calculate calls CalculateFunc.

func (*HashStub) CalculateCalls

func (mock *HashStub) CalculateCalls() []struct {
	FilePath string
}

CalculateCalls gets all the calls that were made to Calculate. Check the length with:

len(mockedHash.CalculateCalls())

func (*HashStub) Verify

func (mock *HashStub) Verify(filePath string, expectedChecksum string) error

Verify calls VerifyFunc.

func (*HashStub) VerifyCalls

func (mock *HashStub) VerifyCalls() []struct {
	FilePath         string
	ExpectedChecksum string
}

VerifyCalls gets all the calls that were made to Verify. Check the length with:

len(mockedHash.VerifyCalls())

type Store

type Store interface {
	UploadFile(remotePath, localPath, checksum string) error
	DownloadFile(remotePath, localPath string) (checksum string, err error)
}

type StoreStub

type StoreStub struct {
	// DownloadFileFunc mocks the DownloadFile method.
	DownloadFileFunc func(remotePath string, localPath string) (string, error)

	// UploadFileFunc mocks the UploadFile method.
	UploadFileFunc func(remotePath string, localPath string, checksum string) error
	// contains filtered or unexported fields
}

StoreStub is a mock implementation of Store.

func TestSomethingThatUsesStore(t *testing.T) {

	// make and configure a mocked Store
	mockedStore := &StoreStub{
		DownloadFileFunc: func(remotePath string, localPath string) (string, error) {
			panic("mock out the DownloadFile method")
		},
		UploadFileFunc: func(remotePath string, localPath string, checksum string) error {
			panic("mock out the UploadFile method")
		},
	}

	// use mockedStore in code that requires Store
	// and then make assertions.

}

func (*StoreStub) DownloadFile

func (mock *StoreStub) DownloadFile(remotePath string, localPath string) (string, error)

DownloadFile calls DownloadFileFunc.

func (*StoreStub) DownloadFileCalls

func (mock *StoreStub) DownloadFileCalls() []struct {
	RemotePath string
	LocalPath  string
}

DownloadFileCalls gets all the calls that were made to DownloadFile. Check the length with:

len(mockedStore.DownloadFileCalls())

func (*StoreStub) UploadFile

func (mock *StoreStub) UploadFile(remotePath string, localPath string, checksum string) error

UploadFile calls UploadFileFunc.

func (*StoreStub) UploadFileCalls

func (mock *StoreStub) UploadFileCalls() []struct {
	RemotePath string
	LocalPath  string
	Checksum   string
}

UploadFileCalls gets all the calls that were made to UploadFile. Check the length with:

len(mockedStore.UploadFileCalls())

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳