Skip to content

Commit

Permalink
fix vet (#4084)
Browse files Browse the repository at this point in the history
* fix vet

* fix tests

* complete mock handler

* more test

* mockgen
  • Loading branch information
laverya committed Oct 22, 2023
1 parent f77579d commit ad3b291
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 13 deletions.
31 changes: 21 additions & 10 deletions pkg/handlers/handlers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1210,54 +1210,65 @@ var HandlerPolicyTests = map[string][]HandlerPolicyTest{
},

"HelmVM": {}, // Not implemented
"GenerateHelmVMNodeJoinCommandSecondary": {
"GenerateK0sNodeJoinCommand": {
{
Roles: []rbactypes.Role{rbac.ClusterAdminRole},
SessionRoles: []string{rbac.ClusterAdminRoleID},
Calls: func(storeRecorder *mock_store.MockStoreMockRecorder, handlerRecorder *mock_handlers.MockKOTSHandlerMockRecorder) {
handlerRecorder.GenerateHelmVMNodeJoinCommandSecondary(gomock.Any(), gomock.Any())
handlerRecorder.GenerateK0sNodeJoinCommand(gomock.Any(), gomock.Any())
},
ExpectStatus: http.StatusOK,
},
},
"GenerateHelmVMNodeJoinCommandPrimary": {
"DrainHelmVMNode": {
{
Vars: map[string]string{"nodeName": "node-name"},
Roles: []rbactypes.Role{rbac.ClusterAdminRole},
SessionRoles: []string{rbac.ClusterAdminRoleID},
Calls: func(storeRecorder *mock_store.MockStoreMockRecorder, handlerRecorder *mock_handlers.MockKOTSHandlerMockRecorder) {
handlerRecorder.GenerateHelmVMNodeJoinCommandPrimary(gomock.Any(), gomock.Any())
handlerRecorder.DrainHelmVMNode(gomock.Any(), gomock.Any())
},
ExpectStatus: http.StatusOK,
},
},
"DrainHelmVMNode": {
"DeleteHelmVMNode": {
{
Vars: map[string]string{"nodeName": "node-name"},
Roles: []rbactypes.Role{rbac.ClusterAdminRole},
SessionRoles: []string{rbac.ClusterAdminRoleID},
Calls: func(storeRecorder *mock_store.MockStoreMockRecorder, handlerRecorder *mock_handlers.MockKOTSHandlerMockRecorder) {
handlerRecorder.DrainHelmVMNode(gomock.Any(), gomock.Any())
handlerRecorder.DeleteHelmVMNode(gomock.Any(), gomock.Any())
},
ExpectStatus: http.StatusOK,
},
},
"DeleteHelmVMNode": {
"GetHelmVMNodes": {
{
Roles: []rbactypes.Role{rbac.ClusterAdminRole},
SessionRoles: []string{rbac.ClusterAdminRoleID},
Calls: func(storeRecorder *mock_store.MockStoreMockRecorder, handlerRecorder *mock_handlers.MockKOTSHandlerMockRecorder) {
handlerRecorder.GetHelmVMNodes(gomock.Any(), gomock.Any())
},
ExpectStatus: http.StatusOK,
},
},
"GetHelmVMNode": {
{
Vars: map[string]string{"nodeName": "node-name"},
Roles: []rbactypes.Role{rbac.ClusterAdminRole},
SessionRoles: []string{rbac.ClusterAdminRoleID},
Calls: func(storeRecorder *mock_store.MockStoreMockRecorder, handlerRecorder *mock_handlers.MockKOTSHandlerMockRecorder) {
handlerRecorder.DeleteHelmVMNode(gomock.Any(), gomock.Any())
handlerRecorder.GetHelmVMNode(gomock.Any(), gomock.Any())
},
ExpectStatus: http.StatusOK,
},
},
"GetHelmVMNodes": {
"GetK0sNodeJoinCommand": {
{
Roles: []rbactypes.Role{rbac.ClusterAdminRole},
SessionRoles: []string{rbac.ClusterAdminRoleID},
Calls: func(storeRecorder *mock_store.MockStoreMockRecorder, handlerRecorder *mock_handlers.MockKOTSHandlerMockRecorder) {
handlerRecorder.GetHelmVMNodes(gomock.Any(), gomock.Any())
handlerRecorder.GetK0sNodeJoinCommand(gomock.Any(), gomock.Any())
},
ExpectStatus: http.StatusOK,
},
Expand Down
1 change: 1 addition & 0 deletions pkg/handlers/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ type KOTSHandler interface {
DeleteHelmVMNode(w http.ResponseWriter, r *http.Request)
GetHelmVMNodes(w http.ResponseWriter, r *http.Request)
GetHelmVMNode(w http.ResponseWriter, r *http.Request)
GetK0sNodeJoinCommand(w http.ResponseWriter, r *http.Request)

// Prometheus
SetPrometheusAddress(w http.ResponseWriter, r *http.Request)
Expand Down
18 changes: 15 additions & 3 deletions pkg/handlers/mock/mock.go

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

0 comments on commit ad3b291

Please sign in to comment.