testjob

package
v1.8.0 Latest Latest
Warning

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

Go to latest
Published: Apr 20, 2020 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DatasetAPIMock

type DatasetAPIMock struct {
	// CreateInstanceFunc mocks the CreateInstance method.
	CreateInstanceFunc func(ctx context.Context, job *models.Job, recipeInst *models.RecipeInstance) (*models.Instance, error)

	// UpdateInstanceStateFunc mocks the UpdateInstanceState method.
	UpdateInstanceStateFunc func(ctx context.Context, instanceID string, newState string) error
	// contains filtered or unexported fields
}

DatasetAPIMock is a mock implementation of job.DatasetAPI.

    func TestSomethingThatUsesDatasetAPI(t *testing.T) {

        // make and configure a mocked job.DatasetAPI
        mockedDatasetAPI := &DatasetAPIMock{
            CreateInstanceFunc: func(ctx context.Context, job *models.Job, recipeInst *models.RecipeInstance) (*models.Instance, error) {
	               panic("mock out the CreateInstance method")
            },
            UpdateInstanceStateFunc: func(ctx context.Context, instanceID string, newState string) error {
	               panic("mock out the UpdateInstanceState method")
            },
        }

        // use mockedDatasetAPI in code that requires job.DatasetAPI
        // and then make assertions.

    }

func (*DatasetAPIMock) CreateInstance

func (mock *DatasetAPIMock) CreateInstance(ctx context.Context, job *models.Job, recipeInst *models.RecipeInstance) (*models.Instance, error)

CreateInstance calls CreateInstanceFunc.

func (*DatasetAPIMock) CreateInstanceCalls

func (mock *DatasetAPIMock) CreateInstanceCalls() []struct {
	Ctx        context.Context
	Job        *models.Job
	RecipeInst *models.RecipeInstance
}

CreateInstanceCalls gets all the calls that were made to CreateInstance. Check the length with:

len(mockedDatasetAPI.CreateInstanceCalls())

func (*DatasetAPIMock) UpdateInstanceState

func (mock *DatasetAPIMock) UpdateInstanceState(ctx context.Context, instanceID string, newState string) error

UpdateInstanceState calls UpdateInstanceStateFunc.

func (*DatasetAPIMock) UpdateInstanceStateCalls

func (mock *DatasetAPIMock) UpdateInstanceStateCalls() []struct {
	Ctx        context.Context
	InstanceID string
	NewState   string
}

UpdateInstanceStateCalls gets all the calls that were made to UpdateInstanceState. Check the length with:

len(mockedDatasetAPI.UpdateInstanceStateCalls())

type QueueMock

type QueueMock struct {
	// QueueFunc mocks the Queue method.
	QueueFunc func(ctx context.Context, job *models.ImportData) error
	// contains filtered or unexported fields
}

QueueMock is a mock implementation of job.Queue.

    func TestSomethingThatUsesQueue(t *testing.T) {

        // make and configure a mocked job.Queue
        mockedQueue := &QueueMock{
            QueueFunc: func(ctx context.Context, job *models.ImportData) error {
	               panic("mock out the Queue method")
            },
        }

        // use mockedQueue in code that requires job.Queue
        // and then make assertions.

    }

func (*QueueMock) Queue

func (mock *QueueMock) Queue(ctx context.Context, job *models.ImportData) error

Queue calls QueueFunc.

func (*QueueMock) QueueCalls

func (mock *QueueMock) QueueCalls() []struct {
	Ctx context.Context
	Job *models.ImportData
}

QueueCalls gets all the calls that were made to Queue. Check the length with:

len(mockedQueue.QueueCalls())

type RecipeAPIMock

type RecipeAPIMock struct {
	// GetRecipeFunc mocks the GetRecipe method.
	GetRecipeFunc func(ctx context.Context, ID string) (*models.Recipe, error)
	// contains filtered or unexported fields
}

RecipeAPIMock is a mock implementation of job.RecipeAPI.

    func TestSomethingThatUsesRecipeAPI(t *testing.T) {

        // make and configure a mocked job.RecipeAPI
        mockedRecipeAPI := &RecipeAPIMock{
            GetRecipeFunc: func(ctx context.Context, ID string) (*models.Recipe, error) {
	               panic("mock out the GetRecipe method")
            },
        }

        // use mockedRecipeAPI in code that requires job.RecipeAPI
        // and then make assertions.

    }

func (*RecipeAPIMock) GetRecipe

func (mock *RecipeAPIMock) GetRecipe(ctx context.Context, ID string) (*models.Recipe, error)

GetRecipe calls GetRecipeFunc.

func (*RecipeAPIMock) GetRecipeCalls

func (mock *RecipeAPIMock) GetRecipeCalls() []struct {
	Ctx context.Context
	ID  string
}

GetRecipeCalls gets all the calls that were made to GetRecipe. Check the length with:

len(mockedRecipeAPI.GetRecipeCalls())

Jump to

Keyboard shortcuts

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