triggers_test.go | |
---|---|
|
|
Unit tests checking functions for manipulation with triggers via REST API. |
|
Documentation in literate-programming-style is available at: https://redhatinsights.github.io/insights-operator-cli/packages/commands/commands_test.html |
|
tryToFindTrigger is a helper function that tries to find a trigger ID in captured output. If trigger info is not found, the test that calls this function, fails. |
|
if trigger info is not found, the test should fail |
|
TestListOfTriggers function checks whether the non-empty list of triggers read via REST API is displayed correctly on CLI client standard output. |
|
turn off any colorization on standard output so we'll be able to capture pure messages w/o terminal control codes |
|
use mocked REST API instead of the real one to perform trigger-related command or query |
|
use go-capture package to capture all writes to standard output |
|
check if capture was done correctly |
|
test the captured output |
|
we expect six lines - title, column headers and four triggers |
|
list of expected triggers to be displayed on standard output |
|
check the actual output displayed on terminal |
|
TestListOfTriggers function checks whether the empty list of triggers read via REST API is displayed correctly. |
|
turn off any colorization on standard output so we'll be able to capture pure messages w/o terminal control codes |
|
use mocked REST API instead of the real one to perform trigger-related command or query |
|
use go-capture package to capture all writes to standard output |
|
check if capture was done correctly |
|
test the captured output |
|
we expect two lines - title and column headers |
|
check the actual output displayed on terminal |
|
TestListOfTriggersErrorHandling function checks whether error returned by REST API is handled correctly. |
|
turn off any colorization on standard output so we'll be able to capture pure messages w/o terminal control codes |
|
use mocked REST API instead of the real one to perform trigger-related command or query |
|
use go-capture package to capture all writes to standard output |
|
check if capture was done correctly |
|
check the actual output displayed on terminal |
|
TestDescribeActivatedTrigger function checks whether it is possible to read and displays information about activated trigger. |
|
turn off any colorization on standard output so we'll be able to capture pure messages w/o terminal control codes |
|
use mocked REST API instead of the real one to perform trigger-related command or query |
|
use go-capture package to capture all writes to standard output |
|
check if capture was done correctly |
|
check the actual output displayed on terminal |
|
cluster ID needs to be displayed |
|
user name needs to be displayed |
|
info about activated trigger needs to be displayed |
|
TestDescribeInactivatedTrigger function checks whether it is possible to read and displays information about inactivated trigger. |
|
turn off any colorization on standard output so we'll be able to capture pure messages w/o terminal control codes |
|
use mocked REST API instead of the real one to perform trigger-related command or query |
|
use go-capture package to capture all writes to standard output |
|
check if capture was done correctly |
|
test the captured output |
|
cluster ID needs to be displayed |
|
user name needs to be displayed |
|
info about inactivated trigger needs to be displayed |
|
TestDescribeNonMustGatherTrigger function checks whether it is possible to read and displays information about other type of trigger. |
|
turn off any colorization on standard output so we'll be able to capture pure messages w/o terminal control codes |
|
use mocked REST API instead of the real one to perform trigger-related command or query |
|
use go-capture package to capture all writes to standard output |
|
check if capture was done correctly |
|
test the captured output |
|
cluster ID needs to be displayed |
|
user name needs to be displayed |
|
info about inactivated trigger needs to be displayed |
|
TestDescribeTriggerErrorHandling function checks how REST API-related issues are reported and handled. |
|
turn off any colorization on standard output so we'll be able to capture pure messages w/o terminal control codes |
|
use mocked REST API instead of the real one to perform trigger-related command or query |
|
use go-capture package to capture all writes to standard output |
|
check if capture was done correctly |
|
test the captured output |
|
TestAddTriggerImpl function checks the ability to add a new trigger via REST API. |
|
turn off any colorization on standard output so we'll be able to capture pure messages w/o terminal control codes |
|
use mocked REST API instead of the real one to perform trigger-related command or query |
|
use go-capture package to capture all writes to standard output |
|
check if capture was done correctly |
|
test the captured output |
|
TestAddTriggerImplError function checks error handling during new trigger registration. |
|
turn off any colorization on standard output so we'll be able to capture pure messages w/o terminal control codes |
|
use mocked REST API instead of the real one to perform trigger-related command or query |
|
use go-capture package to capture all writes to standard output |
|
check if capture was done correctly |
|
test the captured output |
|
TestDeleteTrigger function checks. the command 'delete trigger'. |
|
turn off any colorization on standard output so we'll be able to capture pure messages w/o terminal control codes |
|
use mocked REST API instead of the real one to perform trigger-related command or query |
|
use go-capture package to capture all writes to standard output |
|
check if capture was done correctly |
|
test the captured output |
|
TestDeleteTriggerErrorHandling function check error handling for the command 'delete trigger'. |
|
turn off any colorization on standard output so we'll be able to capture pure messages w/o terminal control codes |
|
use mocked REST API instead of the real one to perform trigger-related command or query |
|
use go-capture package to capture all writes to standard output |
|
check if capture was done correctly |
|
test the captured output |
|
TestActivateTrigger function checks the command 'activate trigger'. |
|
turn off any colorization on standard output so we'll be able to capture pure messages w/o terminal control codes |
|
use mocked REST API instead of the real one to perform trigger-related command or query |
|
use go-capture package to capture all writes to standard output |
|
check if capture was done correctly |
|
test the captured output |
|
TestActivateTriggerErrorHandling function checks the error handling for command 'activate trigger'. |
|
turn off any colorization on standard output so we'll be able to capture pure messages w/o terminal control codes |
|
use mocked REST API instead of the real one to perform trigger-related command or query |
|
use go-capture package to capture all writes to standard output |
|
check if capture was done correctly |
|
test the captured output |
|
TestDeactivateTrigger function checks the command 'deactivate trigger'. |
|
turn off any colorization on standard output so we'll be able to capture pure messages w/o terminal control codes |
|
use mocked REST API instead of the real one to perform trigger-related command or query |
|
use go-capture package to capture all writes to standard output |
|
check if capture was done correctly |
|
test the captured output |
|
TestDeactivateTriggerErrorHandling function checks the error handling for command 'deactivate trigger'. |
|
turn off any colorization on standard output so we'll be able to capture pure messages w/o terminal control codes |
|
use mocked REST API instead of the real one to perform trigger-related command or query |
|
use go-capture package to capture all writes to standard output |
|
check if capture was done correctly |
|
test the captured output |
|