Sha256: 765fba4d54218c1d153da26f5bb4e2acc5e88cae47fd7fb778e50085fa03aa64

Contents?: true

Size: 1.9 KB

Versions: 67

Compression:

Stored size: 1.9 KB

Contents

require 'test_plugin_helper'

module Mutations
  module JobInvocations
    class CreateMutationTest < ActiveSupport::TestCase
      let(:host) { FactoryBot.create(:host) }
      let(:job_template) { FactoryBot.create(:job_template, :with_input) }
      let(:cron_line) { '5 * * * *' }
      let(:purpose) { 'test' }
      let(:variables) do
        {
          jobInvocation: {
            hostIds: [host.id],
            jobTemplateId: job_template.id,
            targetingType: 'static_query',
            inputs: { job_template.template_inputs.first.name => "bar" },
            recurrence: {
              cronLine: cron_line,
              purpose:  purpose,
            },
          },
        }
      end

      let(:query) do
        <<-GRAPHQL
          mutation CreateJobInvocation($jobInvocation: JobInvocationInput!) {
              createJobInvocation(input: { jobInvocation: $jobInvocation }) {
                jobInvocation {
                  id
                  description
                  recurringLogic {
                    cronLine
                    purpose
                  }
                }
              }
            }
        GRAPHQL
      end

      context 'with admin user' do
        let(:user) { FactoryBot.create(:user, :admin) }
        let(:context) { { current_user: user } }

        test 'create a job invocation' do
          assert_difference('JobInvocation.count', +1) do
            result = ForemanGraphqlSchema.execute(query, variables: variables, context: context)
            assert_empty result['errors']
            assert_empty result['data']['createJobInvocation']['jobInvocation']['errors']
            assert_equal cron_line, result['data']['createJobInvocation']['jobInvocation']['recurringLogic']['cronLine']
            assert_equal purpose, result['data']['createJobInvocation']['jobInvocation']['recurringLogic']['purpose']
          end
        end
      end
    end
  end
end

Version data entries

67 entries across 67 versions & 1 rubygems

Version Path
foreman_remote_execution-14.1.2 test/graphql/mutations/job_invocations/create_test.rb
foreman_remote_execution-14.1.1 test/graphql/mutations/job_invocations/create_test.rb
foreman_remote_execution-14.0.2 test/graphql/mutations/job_invocations/create_test.rb
foreman_remote_execution-14.0.1 test/graphql/mutations/job_invocations/create_test.rb
foreman_remote_execution-13.2.6 test/graphql/mutations/job_invocations/create_test.rb
foreman_remote_execution-14.0.0 test/graphql/mutations/job_invocations/create_test.rb
foreman_remote_execution-13.2.5 test/graphql/mutations/job_invocations/create_test.rb
foreman_remote_execution-13.2.4 test/graphql/mutations/job_invocations/create_test.rb
foreman_remote_execution-13.2.3 test/graphql/mutations/job_invocations/create_test.rb
foreman_remote_execution-13.2.2 test/graphql/mutations/job_invocations/create_test.rb
foreman_remote_execution-12.0.7 test/graphql/mutations/job_invocations/create_test.rb
foreman_remote_execution-13.2.1 test/graphql/mutations/job_invocations/create_test.rb
foreman_remote_execution-13.2.0 test/graphql/mutations/job_invocations/create_test.rb
foreman_remote_execution-10.1.3 test/graphql/mutations/job_invocations/create.rb
foreman_remote_execution-13.0.0 test/graphql/mutations/job_invocations/create_test.rb
foreman_remote_execution-12.0.5 test/graphql/mutations/job_invocations/create_test.rb
foreman_remote_execution-12.0.4 test/graphql/mutations/job_invocations/create_test.rb
foreman_remote_execution-12.0.1 test/graphql/mutations/job_invocations/create_test.rb
foreman_remote_execution-12.0.2 test/graphql/mutations/job_invocations/create_test.rb
foreman_remote_execution-11.1.3 test/graphql/mutations/job_invocations/create.rb