container_repositories.rb 749 Bytes
Newer Older
1 2
FactoryGirl.define do
  factory :container_repository do
3
    name 'test_container_image'
4 5 6
    project

    transient do
7
      tags []
8 9
    end

10 11 12 13
    trait :root do
      name ''
    end

14
    after(:build) do |repository, evaluator|
15 16 17 18 19 20 21 22 23 24
      next if evaluator.tags.to_a.none?

      allow(repository.client)
        .to receive(:repository_tags)
        .and_return({
          'name' => repository.path,
          'tags' => evaluator.tags
        })

      evaluator.tags.each do |tag|
25
        allow(repository.client)
26 27 28 29
          .to receive(:repository_tag_digest)
          .with(repository.path, tag)
          .and_return('sha256:4c8e63ca4cb663ce6c688cb06f1c3' \
                      '72b088dac5b6d7ad7d49cd620d85cf72a15')
30
      end
31 32 33
    end
  end
end