2021-01-03 14:25:43 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
RSpec.describe Resolvers::Terraform::StatesResolver do
|
|
|
|
include GraphqlHelpers
|
|
|
|
|
2021-03-11 19:13:27 +05:30
|
|
|
it { expect(described_class).to have_nullable_graphql_type(Types::Terraform::StateType.connection_type) }
|
2021-01-03 14:25:43 +05:30
|
|
|
it { expect(described_class.null).to be_truthy }
|
|
|
|
|
|
|
|
describe '#resolve' do
|
|
|
|
let_it_be(:project) { create(:project) }
|
|
|
|
|
|
|
|
let_it_be(:production_state) { create(:terraform_state, project: project) }
|
|
|
|
let_it_be(:staging_state) { create(:terraform_state, project: project) }
|
|
|
|
let_it_be(:other_state) { create(:terraform_state) }
|
|
|
|
|
|
|
|
let(:ctx) { Hash(current_user: user) }
|
|
|
|
let(:user) { create(:user, developer_projects: [project]) }
|
|
|
|
|
|
|
|
subject { resolve(described_class, obj: project, ctx: ctx) }
|
|
|
|
|
|
|
|
it 'returns states associated with the agent' do
|
|
|
|
expect(subject).to contain_exactly(production_state, staging_state)
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'user does not have permission' do
|
|
|
|
let(:user) { create(:user) }
|
|
|
|
|
|
|
|
it { is_expected.to be_empty }
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2021-03-11 19:13:27 +05:30
|
|
|
|
|
|
|
RSpec.describe Resolvers::Terraform::StatesResolver.single do
|
|
|
|
it { expect(described_class).to be < Resolvers::Terraform::StatesResolver }
|
|
|
|
|
|
|
|
describe 'arguments' do
|
|
|
|
subject { described_class.arguments[argument] }
|
|
|
|
|
|
|
|
describe 'name' do
|
|
|
|
let(:argument) { 'name' }
|
|
|
|
|
|
|
|
it do
|
|
|
|
expect(subject).to be_present
|
|
|
|
expect(subject.type.to_s).to eq('String!')
|
|
|
|
expect(subject.description).to be_present
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|