- test "check active and success for a pipeline in new state" do
- pi = pipeline_instances :new_pipeline
-
- assert !pi.active, 'expected active to be false for a new pipeline'
- assert !pi.success, 'expected success to be false for a new pipeline'
- assert !pi.state, 'expected state to be nil because the fixture had no state specified'
-
- # save the pipeline and expect state to be New
- Thread.current[:user] = users(:admin)
-
- pi.save
- pi = PipelineInstance.find_by_uuid 'zzzzz-xxxxx-f4gneyn6br1xize'
- assert_equal PipelineInstance::New, pi.state, 'expected state to be New for new pipeline'
- assert !pi.active, 'expected active to be false for a new pipeline'
- assert !pi.success, 'expected success to be false for a new pipeline'
- end
-
- test "update attributes for pipeline" do
- Thread.current[:user] = users(:admin)
-
- pi = pipeline_instances :new_pipeline
-
- # add a component with no input and expect state to be New
- component = {'script_parameters' => {"input_not_provided" => {"required" => true}}}
- pi.components['first'] = component
- components = pi.components
- pi.update_attribute 'components', pi.components
- pi = PipelineInstance.find_by_uuid 'zzzzz-xxxxx-f4gneyn6br1xize'
- assert_equal PipelineInstance::New, pi.state, 'expected state to be New after adding component with input'
- assert_equal pi.components.size, 1, 'expected one component'
- assert !pi.active, 'expected active to be false after update'
- assert !pi.success, 'expected success to be false for a new pipeline'
-
- # add a component with no input not required
- component = {'script_parameters' => {"input_not_provided" => {"required" => false}}}
- pi.components['first'] = component
- components = pi.components
- pi.update_attribute 'components', pi.components
- pi = PipelineInstance.find_by_uuid 'zzzzz-xxxxx-f4gneyn6br1xize'
- assert_equal PipelineInstance::Ready, pi.state, 'expected state to be Ready after adding component with input'
- assert_equal pi.components.size, 1, 'expected one component'
- assert !pi.active, 'expected active to be false after update'
- assert !pi.success, 'expected success to be false for a new pipeline'
-
- # add a component with input and expect state to become Ready
- component = {'script_parameters' => {"input" => "yyyad4b39ca5a924e481008009d94e32+210"}}
- pi.components['first'] = component
- components = pi.components
- pi.update_attribute 'components', pi.components
- pi = PipelineInstance.find_by_uuid 'zzzzz-xxxxx-f4gneyn6br1xize'
- assert_equal PipelineInstance::Ready, pi.state, 'expected state to be Ready after adding component with input'
- assert_equal pi.components.size, 1, 'expected one component'
- assert !pi.active, 'expected active to be false after update'
- assert !pi.success, 'expected success to be false for a new pipeline'
-
- pi.active = true
- pi.save
- pi = PipelineInstance.find_by_uuid 'zzzzz-xxxxx-f4gneyn6br1xize'
- assert_equal PipelineInstance::RunningOnServer, pi.state, 'expected state to be RunningOnServer after updating active to true'
- assert pi.active, 'expected active to be true after update'
- assert !pi.success, 'expected success to be false for a new pipeline'