mock

package
v1.3.0 Latest Latest
Warning

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

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

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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 added in v0.15.0

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

CreateProject adds a project to the internal mock

func (*Store) DeleteBuild added in v0.19.0

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

DeleteBuild fakes a build deletion.

func (*Store) DeleteProject added in v0.15.0

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 added in v0.15.0

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 added in v0.20.0

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 added in v1.3.0

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 added in v0.15.0

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

GetWorkerLogStreamFollow gets a readcloser of the mock log data.

func (*Store) ReplaceProject added in v0.20.0

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