cli/pkg/updater/mock_github_client_test.go
Snider 4e02d5bc97 refactor: bring external packages home and restructure
- Imported packages from separate repos:
  - github.com/Snider/config -> pkg/config
  - github.com/Snider/display -> pkg/display
  - github.com/Snider/help -> pkg/help
  - github.com/Snider/i18n -> pkg/i18n
  - github.com/Snider/updater -> pkg/updater
- Moved core code from root to pkg/core
- Flattened nested package structures
- Updated all import paths to github.com/Snider/Core/pkg/*
- Added Display interface to Core
- Updated go.work for workspace modules

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-15 15:30:43 +00:00

36 lines
1.4 KiB
Go

package updater
import (
"context"
)
// MockGithubClient is a mock implementation of the GithubClient interface for testing.
type MockGithubClient struct {
GetLatestReleaseFunc func(ctx context.Context, owner, repo, channel string) (*Release, error)
GetReleaseByPullRequestFunc func(ctx context.Context, owner, repo string, prNumber int) (*Release, error)
GetPublicReposFunc func(ctx context.Context, userOrOrg string) ([]string, error)
}
// GetLatestRelease mocks the GetLatestRelease method of the GithubClient interface.
func (m *MockGithubClient) GetLatestRelease(ctx context.Context, owner, repo, channel string) (*Release, error) {
if m.GetLatestReleaseFunc != nil {
return m.GetLatestReleaseFunc(ctx, owner, repo, channel)
}
return nil, nil
}
// GetReleaseByPullRequest mocks the GetReleaseByPullRequest method of the GithubClient interface.
func (m *MockGithubClient) GetReleaseByPullRequest(ctx context.Context, owner, repo string, prNumber int) (*Release, error) {
if m.GetReleaseByPullRequestFunc != nil {
return m.GetReleaseByPullRequestFunc(ctx, owner, repo, prNumber)
}
return nil, nil
}
// GetPublicRepos mocks the GetPublicRepos method of the GithubClient interface.
func (m *MockGithubClient) GetPublicRepos(ctx context.Context, userOrOrg string) ([]string, error) {
if m.GetPublicReposFunc != nil {
return m.GetPublicReposFunc(ctx, userOrOrg)
}
return []string{"repo1", "repo2"}, nil
}