engine

package
v0.9.1 Latest Latest
Warning

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

Go to latest
Published: Aug 29, 2023 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package engine contains implementations of task.Tracker for different task providers.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Interface

type Interface interface {
	// List lists tasks by their IDs.
	List(ctx context.Context, ids []string) ([]task.Ticket, error)
	// Get returns a single task by its ID.
	Get(ctx context.Context, id string) (task.Ticket, error)
}

Interface defines methods for task tracker engines.

type InterfaceMock

type InterfaceMock struct {
	// GetFunc mocks the Get method.
	GetFunc func(ctx context.Context, id string) (task.Ticket, error)

	// ListFunc mocks the List method.
	ListFunc func(ctx context.Context, ids []string) ([]task.Ticket, error)
	// contains filtered or unexported fields
}

InterfaceMock is a mock implementation of Interface.

func TestSomethingThatUsesInterface(t *testing.T) {

	// make and configure a mocked Interface
	mockedInterface := &InterfaceMock{
		GetFunc: func(ctx context.Context, id string) (task.Ticket, error) {
			panic("mock out the Get method")
		},
		ListFunc: func(ctx context.Context, ids []string) ([]task.Ticket, error) {
			panic("mock out the List method")
		},
	}

	// use mockedInterface in code that requires Interface
	// and then make assertions.

}

func (*InterfaceMock) Get

func (mock *InterfaceMock) Get(ctx context.Context, id string) (task.Ticket, error)

Get calls GetFunc.

func (*InterfaceMock) GetCalls

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

GetCalls gets all the calls that were made to Get. Check the length with:

len(mockedInterface.GetCalls())

func (*InterfaceMock) List

func (mock *InterfaceMock) List(ctx context.Context, ids []string) ([]task.Ticket, error)

List calls ListFunc.

func (*InterfaceMock) ListCalls

func (mock *InterfaceMock) ListCalls() []struct {
	Ctx context.Context
	Ids []string
}

ListCalls gets all the calls that were made to List. Check the length with:

len(mockedInterface.ListCalls())

type Jira

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

Jira is a Jira task tracker engine.

func NewJira

func NewJira(ctx context.Context, params JiraParams) (*Jira, error)

NewJira creates a new Jira engine.

func (*Jira) Get

func (j *Jira) Get(ctx context.Context, key string) (task.Ticket, error)

Get returns a single task by its ID.

func (*Jira) List

func (j *Jira) List(ctx context.Context, keys []string) ([]task.Ticket, error)

List lists tasks from the provided project by their IDs.

type JiraParams

type JiraParams struct {
	URL        string
	Token      string
	HTTPClient http.Client
}

JiraParams is a set of parameters for Jira engine.

type Tracker

type Tracker struct {
	Interface
}

Tracker is a wrapper for task tracker engine with common functions for each tracker implementation.

func (*Tracker) List

func (s *Tracker) List(ctx context.Context, ids []string, loadParents bool) ([]task.Ticket, error)

List lists tasks by their IDs and parents, if flag is set.

type Unsupported

type Unsupported struct{}

Unsupported is a tracker implementation that returns an error for each method.

func (Unsupported) Get

Get returns an error.

func (Unsupported) List

List returns an error.

Jump to

Keyboard shortcuts

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