Documentation ¶
Index ¶
- type BigQueryMock
- func (mock *BigQueryMock) CreateTable(ctx context.Context, table types.BQTableID, md *bigquery.TableMetadata) error
- func (mock *BigQueryMock) CreateTableCalls() []struct{ ... }
- func (mock *BigQueryMock) GetMetadata(ctx context.Context, table types.BQTableID) (*bigquery.TableMetadata, error)
- func (mock *BigQueryMock) GetMetadataCalls() []struct{ ... }
- func (mock *BigQueryMock) Insert(ctx context.Context, tableID types.BQTableID, schema bigquery.Schema, data any) error
- func (mock *BigQueryMock) InsertCalls() []struct{ ... }
- func (mock *BigQueryMock) UpdateTable(ctx context.Context, table types.BQTableID, md bigquery.TableMetadataToUpdate, ...) error
- func (mock *BigQueryMock) UpdateTableCalls() []struct{ ... }
- type GitHubMock
- func (mock *GitHubMock) CreateCheckRun(ctx context.Context, id types.GitHubAppInstallID, repo *model.GitHubRepo, ...) (int64, error)
- func (mock *GitHubMock) CreateCheckRunCalls() []struct{ ... }
- func (mock *GitHubMock) CreateIssueComment(ctx context.Context, repo *model.GitHubRepo, id types.GitHubAppInstallID, ...) error
- func (mock *GitHubMock) CreateIssueCommentCalls() []struct{ ... }
- func (mock *GitHubMock) GetArchiveURL(ctx context.Context, input *interfaces.GetArchiveURLInput) (*url.URL, error)
- func (mock *GitHubMock) GetArchiveURLCalls() []struct{ ... }
- func (mock *GitHubMock) ListIssueComments(ctx context.Context, repo *model.GitHubRepo, id types.GitHubAppInstallID, ...) ([]*model.GitHubIssueComment, error)
- func (mock *GitHubMock) ListIssueCommentsCalls() []struct{ ... }
- func (mock *GitHubMock) MinimizeComment(ctx context.Context, repo *model.GitHubRepo, id types.GitHubAppInstallID, ...) error
- func (mock *GitHubMock) MinimizeCommentCalls() []struct{ ... }
- func (mock *GitHubMock) UpdateCheckRun(ctx context.Context, id types.GitHubAppInstallID, repo *model.GitHubRepo, ...) error
- func (mock *GitHubMock) UpdateCheckRunCalls() []struct{ ... }
- type StorageMock
- type UseCaseMock
- func (mock *UseCaseMock) InsertScanResult(ctx context.Context, meta model.GitHubMetadata, report trivy.Report, ...) error
- func (mock *UseCaseMock) InsertScanResultCalls() []struct{ ... }
- func (mock *UseCaseMock) ScanGitHubRepo(ctx context.Context, input *model.ScanGitHubRepoInput) error
- func (mock *UseCaseMock) ScanGitHubRepoCalls() []struct{ ... }
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BigQueryMock ¶
type BigQueryMock struct { // CreateTableFunc mocks the CreateTable method. CreateTableFunc func(ctx context.Context, table types.BQTableID, md *bigquery.TableMetadata) error // GetMetadataFunc mocks the GetMetadata method. GetMetadataFunc func(ctx context.Context, table types.BQTableID) (*bigquery.TableMetadata, error) // InsertFunc mocks the Insert method. InsertFunc func(ctx context.Context, tableID types.BQTableID, schema bigquery.Schema, data any) error // UpdateTableFunc mocks the UpdateTable method. UpdateTableFunc func(ctx context.Context, table types.BQTableID, md bigquery.TableMetadataToUpdate, eTag string) error // contains filtered or unexported fields }
BigQueryMock is a mock implementation of interfaces.BigQuery.
func TestSomethingThatUsesBigQuery(t *testing.T) { // make and configure a mocked interfaces.BigQuery mockedBigQuery := &BigQueryMock{ CreateTableFunc: func(ctx context.Context, table types.BQTableID, md *bigquery.TableMetadata) error { panic("mock out the CreateTable method") }, GetMetadataFunc: func(ctx context.Context, table types.BQTableID) (*bigquery.TableMetadata, error) { panic("mock out the GetMetadata method") }, InsertFunc: func(ctx context.Context, tableID types.BQTableID, schema bigquery.Schema, data any) error { panic("mock out the Insert method") }, UpdateTableFunc: func(ctx context.Context, table types.BQTableID, md bigquery.TableMetadataToUpdate, eTag string) error { panic("mock out the UpdateTable method") }, } // use mockedBigQuery in code that requires interfaces.BigQuery // and then make assertions. }
func (*BigQueryMock) CreateTable ¶
func (mock *BigQueryMock) CreateTable(ctx context.Context, table types.BQTableID, md *bigquery.TableMetadata) error
CreateTable calls CreateTableFunc.
func (*BigQueryMock) CreateTableCalls ¶
func (mock *BigQueryMock) CreateTableCalls() []struct { Ctx context.Context Table types.BQTableID Md *bigquery.TableMetadata }
CreateTableCalls gets all the calls that were made to CreateTable. Check the length with:
len(mockedBigQuery.CreateTableCalls())
func (*BigQueryMock) GetMetadata ¶
func (mock *BigQueryMock) GetMetadata(ctx context.Context, table types.BQTableID) (*bigquery.TableMetadata, error)
GetMetadata calls GetMetadataFunc.
func (*BigQueryMock) GetMetadataCalls ¶
func (mock *BigQueryMock) GetMetadataCalls() []struct { Ctx context.Context Table types.BQTableID }
GetMetadataCalls gets all the calls that were made to GetMetadata. Check the length with:
len(mockedBigQuery.GetMetadataCalls())
func (*BigQueryMock) Insert ¶
func (mock *BigQueryMock) Insert(ctx context.Context, tableID types.BQTableID, schema bigquery.Schema, data any) error
Insert calls InsertFunc.
func (*BigQueryMock) InsertCalls ¶
func (mock *BigQueryMock) InsertCalls() []struct { Ctx context.Context TableID types.BQTableID Schema bigquery.Schema Data any }
InsertCalls gets all the calls that were made to Insert. Check the length with:
len(mockedBigQuery.InsertCalls())
func (*BigQueryMock) UpdateTable ¶
func (mock *BigQueryMock) UpdateTable(ctx context.Context, table types.BQTableID, md bigquery.TableMetadataToUpdate, eTag string) error
UpdateTable calls UpdateTableFunc.
func (*BigQueryMock) UpdateTableCalls ¶
func (mock *BigQueryMock) UpdateTableCalls() []struct { Ctx context.Context Table types.BQTableID Md bigquery.TableMetadataToUpdate ETag string }
UpdateTableCalls gets all the calls that were made to UpdateTable. Check the length with:
len(mockedBigQuery.UpdateTableCalls())
type GitHubMock ¶
type GitHubMock struct { // CreateCheckRunFunc mocks the CreateCheckRun method. CreateCheckRunFunc func(ctx context.Context, id types.GitHubAppInstallID, repo *model.GitHubRepo, commit string) (int64, error) // CreateIssueCommentFunc mocks the CreateIssueComment method. CreateIssueCommentFunc func(ctx context.Context, repo *model.GitHubRepo, id types.GitHubAppInstallID, prID int, body string) error // GetArchiveURLFunc mocks the GetArchiveURL method. GetArchiveURLFunc func(ctx context.Context, input *interfaces.GetArchiveURLInput) (*url.URL, error) // ListIssueCommentsFunc mocks the ListIssueComments method. ListIssueCommentsFunc func(ctx context.Context, repo *model.GitHubRepo, id types.GitHubAppInstallID, prID int) ([]*model.GitHubIssueComment, error) // MinimizeCommentFunc mocks the MinimizeComment method. MinimizeCommentFunc func(ctx context.Context, repo *model.GitHubRepo, id types.GitHubAppInstallID, subjectID string) error // UpdateCheckRunFunc mocks the UpdateCheckRun method. UpdateCheckRunFunc func(ctx context.Context, id types.GitHubAppInstallID, repo *model.GitHubRepo, checkID int64, opt *github.UpdateCheckRunOptions) error // contains filtered or unexported fields }
GitHubMock is a mock implementation of interfaces.GitHub.
func TestSomethingThatUsesGitHub(t *testing.T) { // make and configure a mocked interfaces.GitHub mockedGitHub := &GitHubMock{ CreateCheckRunFunc: func(ctx context.Context, id types.GitHubAppInstallID, repo *model.GitHubRepo, commit string) (int64, error) { panic("mock out the CreateCheckRun method") }, CreateIssueCommentFunc: func(ctx context.Context, repo *model.GitHubRepo, id types.GitHubAppInstallID, prID int, body string) error { panic("mock out the CreateIssueComment method") }, GetArchiveURLFunc: func(ctx context.Context, input *interfaces.GetArchiveURLInput) (*url.URL, error) { panic("mock out the GetArchiveURL method") }, ListIssueCommentsFunc: func(ctx context.Context, repo *model.GitHubRepo, id types.GitHubAppInstallID, prID int) ([]*model.GitHubIssueComment, error) { panic("mock out the ListIssueComments method") }, MinimizeCommentFunc: func(ctx context.Context, repo *model.GitHubRepo, id types.GitHubAppInstallID, subjectID string) error { panic("mock out the MinimizeComment method") }, UpdateCheckRunFunc: func(ctx context.Context, id types.GitHubAppInstallID, repo *model.GitHubRepo, checkID int64, opt *github.UpdateCheckRunOptions) error { panic("mock out the UpdateCheckRun method") }, } // use mockedGitHub in code that requires interfaces.GitHub // and then make assertions. }
func (*GitHubMock) CreateCheckRun ¶
func (mock *GitHubMock) CreateCheckRun(ctx context.Context, id types.GitHubAppInstallID, repo *model.GitHubRepo, commit string) (int64, error)
CreateCheckRun calls CreateCheckRunFunc.
func (*GitHubMock) CreateCheckRunCalls ¶
func (mock *GitHubMock) CreateCheckRunCalls() []struct { Ctx context.Context ID types.GitHubAppInstallID Repo *model.GitHubRepo Commit string }
CreateCheckRunCalls gets all the calls that were made to CreateCheckRun. Check the length with:
len(mockedGitHub.CreateCheckRunCalls())
func (*GitHubMock) CreateIssueComment ¶
func (mock *GitHubMock) CreateIssueComment(ctx context.Context, repo *model.GitHubRepo, id types.GitHubAppInstallID, prID int, body string) error
CreateIssueComment calls CreateIssueCommentFunc.
func (*GitHubMock) CreateIssueCommentCalls ¶
func (mock *GitHubMock) CreateIssueCommentCalls() []struct { Ctx context.Context Repo *model.GitHubRepo ID types.GitHubAppInstallID PrID int Body string }
CreateIssueCommentCalls gets all the calls that were made to CreateIssueComment. Check the length with:
len(mockedGitHub.CreateIssueCommentCalls())
func (*GitHubMock) GetArchiveURL ¶
func (mock *GitHubMock) GetArchiveURL(ctx context.Context, input *interfaces.GetArchiveURLInput) (*url.URL, error)
GetArchiveURL calls GetArchiveURLFunc.
func (*GitHubMock) GetArchiveURLCalls ¶
func (mock *GitHubMock) GetArchiveURLCalls() []struct { Ctx context.Context Input *interfaces.GetArchiveURLInput }
GetArchiveURLCalls gets all the calls that were made to GetArchiveURL. Check the length with:
len(mockedGitHub.GetArchiveURLCalls())
func (*GitHubMock) ListIssueComments ¶
func (mock *GitHubMock) ListIssueComments(ctx context.Context, repo *model.GitHubRepo, id types.GitHubAppInstallID, prID int) ([]*model.GitHubIssueComment, error)
ListIssueComments calls ListIssueCommentsFunc.
func (*GitHubMock) ListIssueCommentsCalls ¶
func (mock *GitHubMock) ListIssueCommentsCalls() []struct { Ctx context.Context Repo *model.GitHubRepo ID types.GitHubAppInstallID PrID int }
ListIssueCommentsCalls gets all the calls that were made to ListIssueComments. Check the length with:
len(mockedGitHub.ListIssueCommentsCalls())
func (*GitHubMock) MinimizeComment ¶
func (mock *GitHubMock) MinimizeComment(ctx context.Context, repo *model.GitHubRepo, id types.GitHubAppInstallID, subjectID string) error
MinimizeComment calls MinimizeCommentFunc.
func (*GitHubMock) MinimizeCommentCalls ¶
func (mock *GitHubMock) MinimizeCommentCalls() []struct { Ctx context.Context Repo *model.GitHubRepo ID types.GitHubAppInstallID SubjectID string }
MinimizeCommentCalls gets all the calls that were made to MinimizeComment. Check the length with:
len(mockedGitHub.MinimizeCommentCalls())
func (*GitHubMock) UpdateCheckRun ¶
func (mock *GitHubMock) UpdateCheckRun(ctx context.Context, id types.GitHubAppInstallID, repo *model.GitHubRepo, checkID int64, opt *github.UpdateCheckRunOptions) error
UpdateCheckRun calls UpdateCheckRunFunc.
func (*GitHubMock) UpdateCheckRunCalls ¶
func (mock *GitHubMock) UpdateCheckRunCalls() []struct { Ctx context.Context ID types.GitHubAppInstallID Repo *model.GitHubRepo CheckID int64 Opt *github.UpdateCheckRunOptions }
UpdateCheckRunCalls gets all the calls that were made to UpdateCheckRun. Check the length with:
len(mockedGitHub.UpdateCheckRunCalls())
type StorageMock ¶
func NewStorageMock ¶
func NewStorageMock() *StorageMock
func (*StorageMock) Get ¶
func (s *StorageMock) Get(ctx context.Context, key string) (io.ReadCloser, error)
Get implements Storage.
func (*StorageMock) Put ¶
func (s *StorageMock) Put(ctx context.Context, key string, r io.ReadCloser) error
Put implements Storage.
func (*StorageMock) Unmarshal ¶
func (s *StorageMock) Unmarshal(key string, v interface{}) error
type UseCaseMock ¶
type UseCaseMock struct { // InsertScanResultFunc mocks the InsertScanResult method. InsertScanResultFunc func(ctx context.Context, meta model.GitHubMetadata, report trivy.Report, cfg model.Config) error // ScanGitHubRepoFunc mocks the ScanGitHubRepo method. ScanGitHubRepoFunc func(ctx context.Context, input *model.ScanGitHubRepoInput) error // contains filtered or unexported fields }
UseCaseMock is a mock implementation of interfaces.UseCase.
func TestSomethingThatUsesUseCase(t *testing.T) { // make and configure a mocked interfaces.UseCase mockedUseCase := &UseCaseMock{ InsertScanResultFunc: func(ctx context.Context, meta model.GitHubMetadata, report trivy.Report, cfg model.Config) error { panic("mock out the InsertScanResult method") }, ScanGitHubRepoFunc: func(ctx context.Context, input *model.ScanGitHubRepoInput) error { panic("mock out the ScanGitHubRepo method") }, } // use mockedUseCase in code that requires interfaces.UseCase // and then make assertions. }
func (*UseCaseMock) InsertScanResult ¶
func (mock *UseCaseMock) InsertScanResult(ctx context.Context, meta model.GitHubMetadata, report trivy.Report, cfg model.Config) error
InsertScanResult calls InsertScanResultFunc.
func (*UseCaseMock) InsertScanResultCalls ¶
func (mock *UseCaseMock) InsertScanResultCalls() []struct { Ctx context.Context Meta model.GitHubMetadata Report trivy.Report Cfg model.Config }
InsertScanResultCalls gets all the calls that were made to InsertScanResult. Check the length with:
len(mockedUseCase.InsertScanResultCalls())
func (*UseCaseMock) ScanGitHubRepo ¶
func (mock *UseCaseMock) ScanGitHubRepo(ctx context.Context, input *model.ScanGitHubRepoInput) error
ScanGitHubRepo calls ScanGitHubRepoFunc.
func (*UseCaseMock) ScanGitHubRepoCalls ¶
func (mock *UseCaseMock) ScanGitHubRepoCalls() []struct { Ctx context.Context Input *model.ScanGitHubRepoInput }
ScanGitHubRepoCalls gets all the calls that were made to ScanGitHubRepo. Check the length with:
len(mockedUseCase.ScanGitHubRepoCalls())