-
Notifications
You must be signed in to change notification settings - Fork 974
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: googs1025 <[email protected]>
- Loading branch information
Showing
4 changed files
with
103 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package app | ||
|
||
import ( | ||
"testing" | ||
"volcano.sh/volcano/cmd/controller-manager/app/options" | ||
) | ||
|
||
func TestIsControllerEnabled(t *testing.T) { | ||
testCases := []struct { | ||
name string | ||
gotControllerName string | ||
inputControllers []string | ||
isEnable bool | ||
}{ | ||
{ | ||
name: "all controller should be enable", | ||
gotControllerName: "controller1", | ||
inputControllers: []string{"*"}, | ||
isEnable: true, | ||
}, | ||
{ | ||
name: "gc-controller should be disable", | ||
gotControllerName: "gc-controller", | ||
inputControllers: []string{"-gc-controller", "+jobtemplate-controller", "+jobflow-controller", "+pg-controller", "+queue-controller"}, | ||
isEnable: false, | ||
}, | ||
{ | ||
name: "job-controller should be enable", | ||
gotControllerName: "job-controller", | ||
inputControllers: options.KnownControllers(), | ||
isEnable: true, | ||
}, | ||
{ | ||
name: "job-controller is not in inputControllers, controller4 should be disable", | ||
gotControllerName: "job-controller", | ||
inputControllers: []string{"+gc-controller", "+jobtemplate-controller", "+jobflow-controller"}, | ||
isEnable: false, | ||
}, | ||
} | ||
|
||
for _, tc := range testCases { | ||
result := isControllerEnabled(tc.gotControllerName, tc.inputControllers) | ||
if result != tc.isEnable { | ||
t.Errorf("Expected %s to be enabled: %v, but got: %v", tc.gotControllerName, tc.isEnable, result) | ||
} | ||
} | ||
} |