Skip to content

Commit

Permalink
Add test coverage to token rec (#511)
Browse files Browse the repository at this point in the history
Refactor existing test to use mockery helper functions
Add controller-runtime mock
  • Loading branch information
efiacor authored Feb 27, 2024
1 parent 74a3c57 commit 819bc41
Show file tree
Hide file tree
Showing 6 changed files with 1,043 additions and 57 deletions.
9 changes: 8 additions & 1 deletion controllers/pkg/.mockery.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
with-expecter: true
packages:
github.com/nephio-project/nephio/controllers/pkg/giteaclient:
interfaces:
GiteaClient:
config:
dir: "{{.InterfaceDir}}"
dir: "{{.InterfaceDir}}"
sigs.k8s.io/controller-runtime/pkg/client:
interfaces:
Client:
config:
dir: "mocks/external/{{ .InterfaceName | lower }}"
outpkg: "mocks"
10 changes: 10 additions & 0 deletions controllers/pkg/giteaclient/giteaclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ type GiteaClient interface {
CreateRepo(createRepoOption gitea.CreateRepoOption) (*gitea.Repository, *gitea.Response, error)
EditRepo(userName string, repoCRName string, editRepoOption gitea.EditRepoOption) (*gitea.Repository, *gitea.Response, error)
DeleteAccessToken(value interface{}) (*gitea.Response, error)
ListAccessTokens(opts gitea.ListAccessTokensOptions) ([]*gitea.AccessToken, *gitea.Response, error)
CreateAccessToken(opt gitea.CreateAccessTokenOption) (*gitea.AccessToken, *gitea.Response, error)
}

var lock = &sync.Mutex{}
Expand Down Expand Up @@ -171,3 +173,11 @@ func (r *gc) EditRepo(userName string, repoCRName string, editRepoOption gitea.E
func (r *gc) DeleteAccessToken(value interface{}) (*gitea.Response, error) {
return r.giteaClient.DeleteAccessToken(value)
}

func (r *gc) ListAccessTokens(opts gitea.ListAccessTokensOptions) ([]*gitea.AccessToken, *gitea.Response, error) {
return r.giteaClient.ListAccessTokens(opts)
}

func (r *gc) CreateAccessToken(opt gitea.CreateAccessTokenOption) (*gitea.AccessToken, *gitea.Response, error) {
return r.giteaClient.CreateAccessToken(opt)
}
127 changes: 126 additions & 1 deletion controllers/pkg/giteaclient/mock_GiteaClient.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 819bc41

Please sign in to comment.