Welcome to mirror list, hosted at ThFree Co, Russian Federation.

reusable_project.rb « resource « qa « qa - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 6b33bb9d65d966ecf8f0690f626a94b0eea73da9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# frozen_string_literal: true

module QA
  module Resource
    class ReusableProject < Project
      prepend Reusable

      def initialize
        super

        @add_name_uuid = false
        @name = "reusable_project"
        @reuse_as = :default_project
        @initialize_with_readme = true
      end

      # Confirms that the project can be reused
      #
      # @return [nil] returns nil unless an error is raised
      def validate_reuse_preconditions
        unless reused_name_unique?
          raise ResourceReuseError,
            "Reusable projects must have the same name. The project reused as #{reuse_as} has the name '#{name}' but it should be '#{self.class.resources[reuse_as].name}'"
        end
      end

      # Checks if the project is being reused with the same name.
      #
      # @return [Boolean] true if the project's name is different from another project with the same reuse symbol (reuse_as)
      def reused_name_unique?
        return true unless self.class.resources.key?(reuse_as)

        self.class.resources[reuse_as].name == name
      end

      # Overrides QA::Resource::Project#remove_via_api! to log a debug message stating that removal will happen after
      # the suite completes rather than now.
      #
      # @return [nil]
      def remove_via_api!
        QA::Runtime::Logger.debug("#{self.class.name} - deferring removal until after suite")
      end
    end
  end
end