-
Notifications
You must be signed in to change notification settings - Fork 971
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
89 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,44 @@ | ||
package app | ||
|
||
import "testing" | ||
|
||
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: "controller2 should be disable", | ||
gotControllerName: "controller2", | ||
inputControllers: []string{"+controller1", "-controller2", "controller3", "*"}, | ||
isEnable: false, | ||
}, | ||
{ | ||
name: "controller3 should be enable", | ||
gotControllerName: "controller3", | ||
inputControllers: []string{"+controller1", "-controller2", "controller3"}, | ||
isEnable: true, | ||
}, | ||
{ | ||
name: "controller4 is not in inputControllers, controller4 should be disable", | ||
gotControllerName: "controller4", | ||
inputControllers: []string{"+controller1", "-controller2", "controller3"}, | ||
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) | ||
} | ||
} | ||
} |