mock

package
v0.0.0-...-04f2c18 Latest Latest
Warning

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

Go to latest
Published: Feb 24, 2020 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// Now is the date used in all stub date fields.
	Now = time.Now()
	// StubProject is a Project stub.
	StubProject = &brigade.Project{
		ID:           "project-id",
		Name:         "project-name",
		SharedSecret: "shared-secre3t",
		Secrets:      map[string]interface{}{"key": "value"},
	}
	// StubWorker1 is a stub Worker. It is used in StubBuild1, too.
	StubWorker1 = &brigade.Worker{
		ID:        "worker-id1",
		BuildID:   "build-id1",
		ProjectID: "project-id",
		StartTime: Now,
		EndTime:   Now,
		ExitCode:  0,
		Status:    brigade.JobSucceeded,
	}
	// StubWorker2 is a stub Worker. It is used in StubBuild2, too.
	StubWorker2 = &brigade.Worker{
		ID:        "worker-id2",
		BuildID:   "build-id2",
		ProjectID: "project-id",
		StartTime: Now.AddDate(0, 0, -1),
		EndTime:   Now,
		ExitCode:  0,
		Status:    brigade.JobSucceeded,
	}
	// StubBuild1 is a stub Build.
	StubBuild1 = &brigade.Build{
		ID:        "build-id1",
		ProjectID: "project-id",
		Revision: &brigade.Revision{
			Commit: "commit1",
		},
		Type:     "type",
		Provider: "provider",
		Payload:  []byte("payload"),
		Script:   []byte("script"),
		Worker:   StubWorker1,
	}
	// StubBuild2 is another stub Build.
	StubBuild2 = &brigade.Build{
		ID:        "build-id2",
		ProjectID: "project-id",
		Revision: &brigade.Revision{
			Commit: "commit2",
		},
		Type:     "type",
		Provider: "provider",
		Payload:  []byte("payload"),
		Script:   []byte("script"),
		Worker:   StubWorker2,
	}
	// StubJob is a stub Job.
	StubJob = &brigade.Job{
		ID:           "job-id",
		Name:         "job-name",
		Image:        "image",
		CreationTime: Now,
		StartTime:    Now,
		EndTime:      Now,
		ExitCode:     0,
		Status:       brigade.JobSucceeded,
	}
	// StubLogData is string data representing a log.
	StubLogData = "Hello World"
)

Functions

This section is empty.

Types

type Store

type Store struct {
	// Builds is a slice of Builds.
	Builds []*brigade.Build
	// Job is the job you want returned.
	Job *brigade.Job
	// Workers is a slice of workers.
	Workers []*brigade.Worker
	// LogData is the log data you want returned.
	LogData string
	// ProjectList on this mock
	ProjectList []*brigade.Project
}

Store implements the storage.Storage interface, but returns mock data.

func New

func New() *Store

New returns a new Store with the default stubs.

func (*Store) CreateBuild

func (s *Store) CreateBuild(b *brigade.Build) error

CreateBuild fakes a new build.

func (*Store) CreateProject

func (s *Store) CreateProject(p *brigade.Project) error

CreateProject adds a project to the internal mock

func (*Store) DeleteBuild

func (s *Store) DeleteBuild(bid string, options storage.DeleteBuildOptions) error

DeleteBuild fakes a build deletion.

func (*Store) DeleteProject

func (s *Store) DeleteProject(id string) error

DeleteProject deletes a project from the internal mock

func (*Store) GetBuild

func (s *Store) GetBuild(id string) (*brigade.Build, error)

GetBuild gets the first mock Build.

func (*Store) GetBuildJobs

func (s *Store) GetBuildJobs(b *brigade.Build) ([]*brigade.Job, error)

GetBuildJobs gets the mock job wrapped in a slice.

func (*Store) GetBuilds

func (s *Store) GetBuilds() ([]*brigade.Build, error)

GetBuilds returns the mock build wrapped in a slice.

func (*Store) GetJob

func (s *Store) GetJob(id string) (*brigade.Job, error)

GetJob gets the mock job.

func (*Store) GetJobLog

func (s *Store) GetJobLog(j *brigade.Job) (string, error)

GetJobLog gets the mock log data.

func (*Store) GetJobLogStream

func (s *Store) GetJobLogStream(j *brigade.Job) (io.ReadCloser, error)

GetJobLogStream gets the mock log data as a readcloser.

func (*Store) GetJobLogStreamFollow

func (s *Store) GetJobLogStreamFollow(j *brigade.Job) (io.ReadCloser, error)

GetJobLogStreamFollow gets the mock log data as a readcloser.

func (*Store) GetProject

func (s *Store) GetProject(id string) (*brigade.Project, error)

GetProject returns the Project

func (*Store) GetProjectBuilds

func (s *Store) GetProjectBuilds(p *brigade.Project) ([]*brigade.Build, error)

GetProjectBuilds returns the mock Build wrapped in a slice.

func (*Store) GetProjects

func (s *Store) GetProjects() ([]*brigade.Project, error)

GetProjects gets the mock project wrapped as a slice of projects.

func (*Store) GetStorageClassNames

func (s *Store) GetStorageClassNames() ([]string, error)

GetStorageClassNames returns the names of the StorageClass instances in the cluster

func (*Store) GetWorker

func (s *Store) GetWorker(bid string) (*brigade.Worker, error)

GetWorker gets the first mock worker.

func (*Store) GetWorkerInitLog

func (s *Store) GetWorkerInitLog(w *brigade.Worker) (string, error)

GetWorkerInitLog gets the mock log data.

func (*Store) GetWorkerLog

func (s *Store) GetWorkerLog(w *brigade.Worker) (string, error)

GetWorkerLog gets the mock log data.

func (*Store) GetWorkerLogStream

func (s *Store) GetWorkerLogStream(w *brigade.Worker) (io.ReadCloser, error)

GetWorkerLogStream gets a readcloser of the mock log data.

func (*Store) GetWorkerLogStreamFollow

func (s *Store) GetWorkerLogStreamFollow(w *brigade.Worker) (io.ReadCloser, error)

GetWorkerLogStreamFollow gets a readcloser of the mock log data.

func (*Store) ReplaceProject

func (s *Store) ReplaceProject(p *brigade.Project) error

ReplaceProject replaces a project in the internal mock

Jump to

Keyboard shortcuts

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