Skip to content

Commit

Permalink
Issue minishift#2322 Add integration test step to test experimental f…
Browse files Browse the repository at this point in the history
…eature
  • Loading branch information
amitkrout committed May 7, 2018
1 parent 3f64e64 commit c06ecce
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 0 deletions.
47 changes: 47 additions & 0 deletions test/integration/features/experimental-feature.feature
@@ -0,0 +1,47 @@
@experimental-feature
Feature: Experimental Feature
As a user I can able to enable, run and disable experimental feature

Scenario: User cannot start minishift experimental feature without setting up the environment variable MINISHIFT_ENABLE_EXPERIMENTAL
Given Minishift has state "Does Not Exist"
Then executing "minishift start --extra-clusterup-flags --service-catalog" fails
And stderr should contain
"""
Error: unknown flag: --extra-clusterup-flags
"""

Scenario: User can enable minishift experimental feature
Given Minishift has state "Does Not Exist"
When setting up environment variable "MINISHIFT_ENABLE_EXPERIMENTAL" with value "y" succeeds
Then executing "minishift start -h" succeeds
And stdout should contain
"""
--extra-clusterup-flags string
"""

Scenario: User can start minishift experimental feature
Given Minishift has state "Does Not Exist"
And image caching is disabled
And environment variable "MINISHIFT_ENABLE_EXPERIMENTAL" value should be "y"
Then executing "minishift start --extra-clusterup-flags --service-catalog" succeeds
And stdout should contain
"""
-- Extra 'oc' cluster up flags (experimental) ...
'--service-catalog'
"""

Scenario: User can disable minishift experimental feature
Given Minishift has state "Running"
And environment variable "MINISHIFT_ENABLE_EXPERIMENTAL" value should be "y"
Then unset environment variable "MINISHIFT_ENABLE_EXPERIMENTAL" succeeds
When executing "minishift start --extra-clusterup-flags --service-catalog" fails
Then stderr should contain
"""
Error: unknown flag: --extra-clusterup-flags
"""

Scenario: Deleting Minishift
Given Minishift has state "Running"
When executing "minishift delete --force" succeeds
Then Minishift has state "Does Not Exist"

23 changes: 23 additions & 0 deletions test/integration/testsuite/minishift.go
Expand Up @@ -350,3 +350,26 @@ func (m *Minishift) minishiftHomeDirectoryShouldntExist(dir string) error {

return fmt.Errorf("Directory %s exists", dir)
}

func (m *Minishift) setEnvironmentVariable(variable string, value string) error {
os.Setenv(variable, value)
if os.Getenv(variable) != value {
return fmt.Errorf("Error in setting environment variable %s=%s in the current shell", variable, value)
}
return nil
}

func (m *Minishift) getEnvironmentVariable(variable string, value string) error {
if os.Getenv(variable) != value {
return fmt.Errorf("Environment variable value Expected: %s, Actual: %s in the current shell", value, os.Getenv(variable))
}
return nil
}

func (m *Minishift) unSetEnvironmentVariable(variable string) error {
os.Unsetenv(variable)
if os.Getenv(variable) != "" {
return fmt.Errorf("Error in removing environment variable %s in the current shell", variable)
}
return nil
}
8 changes: 8 additions & 0 deletions test/integration/testsuite/testsuite.go
Expand Up @@ -108,6 +108,14 @@ func FeatureContext(s *godog.Suite) {
s.Step(`^scenario variable "(.*)" should not be empty$`,
variableShouldNotBeEmpty)

// steps for set, get and unset environment variable
s.Step(`^setting up environment variable "(.*)" with value "(.*)" succeeds$`,
MinishiftInstance.setEnvironmentVariable)
s.Step(`^environment variable "(.*)" value should be "(.*)"$`,
MinishiftInstance.getEnvironmentVariable)
s.Step(`^unset environment variable "(.*)" succeeds$`,
MinishiftInstance.unSetEnvironmentVariable)

// steps for rollout check
s.Step(`^services? "([^"]*)" rollout successfully$`,
MinishiftInstance.rolloutServicesSuccessfully)
Expand Down

0 comments on commit c06ecce

Please sign in to comment.