|
package tests
|
Documentation in literate-programming-style is available at:
https://redhatinsights.github.io/insights-operator-controller/packages/tests/rest/operator.html
|
import "github.com/verdverm/frisby"
func checkConfigurationForCluster0 ( ) {
f := frisby . Create ( "Check reading the configuration for cluster 00000000-0000-0000-0000-000000000000" )
f . Get ( API_URL + "/operator/configuration/00000000-0000-0000-0000-000000000000" )
f . Send ( )
f . ExpectStatus ( 200 )
f . ExpectHeader ( "Content-Type" , "application/json; charset=utf-8" )
|
check the content JSON response
|
f . ExpectJson ( "configuration" , "{\"no_op\":\"X\", \"watch\":[\"a\",\"b\",\"c\"]}" )
f . ExpectJson ( "status" , "ok" )
f . PrintReport ( )
}
func checkRegisterNewCluster ( ) {
f := frisby . Create ( "Check if new cluster can be registered" )
f . Put ( API_URL + "/operator/register/00000000-0000-0000-0000-000000000006" )
f . Send ( )
f . ExpectStatus ( 201 )
f . ExpectHeader ( "Content-Type" , "application/json; charset=utf-8" )
}
func checkNonExistingConfiguration ( ) {
f := frisby . Create ( "Try to read configuration that does not exist" )
|
configuration can't exists
|
f . Get ( API_URL + "/operator/configuration/00000000-0000-0000-0000-000000000006" )
f . Send ( )
f . ExpectStatus ( 404 )
f . PrintReport ( )
}
|
OperatorTests run all operator-related REST API tests.
|
func OperatorTests ( ) {
checkConfigurationForCluster0 ( )
|
configuration for non-existing cluster
|
checkNonExistingConfiguration ( )
checkRegisterNewCluster ( )
|
configuration for newly created cluster
|
checkNonExistingConfiguration ( )
|
TODO:
working with clusters with improper names
|
}
|