summaryrefslogtreecommitdiff
path: root/spec/lib/puppet_spec/module_tool/stub_source.rb
blob: 8b5f8bbe184d6970de205b2f3b6f5d98158b68f9 (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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
module PuppetSpec
  module ModuleTool
    class StubSource < Semantic::Dependency::Source
      def inspect; "Stub Source"; end
      def host
        "http://nowhe.re"
      end

      def fetch(name)
        available_releases[name.tr('/', '-')].values
      end

      def available_releases
        return @available_releases if defined? @available_releases

        @available_releases = {
          'puppetlabs-java' => {
            '10.0.0' => { 'puppetlabs/stdlib' => '4.1.0' },
          },
          'puppetlabs-stdlib' => {
            '4.1.0' => {},
          },
          'pmtacceptance-stdlib' => {
            "4.1.0" => {},
            "3.2.0" => {},
            "3.1.0" => {},
            "3.0.0" => {},
            "2.6.0" => {},
            "2.5.1" => {},
            "2.5.0" => {},
            "2.4.0" => {},
            "2.3.2" => {},
            "2.3.1" => {},
            "2.3.0" => {},
            "2.2.1" => {},
            "2.2.0" => {},
            "2.1.3" => {},
            "2.0.0" => {},
            "1.1.0" => {},
            "1.0.0" => {},
          },
          'pmtacceptance-keystone' => {
            '3.0.0-rc2' => { "pmtacceptance/mysql" => ">=0.6.1 <1.0.0", "pmtacceptance/stdlib" => ">= 2.5.0" },
            '3.0.0-rc1' => { "pmtacceptance/mysql" => ">=0.6.1 <1.0.0", "pmtacceptance/stdlib" => ">= 2.5.0" },
            '2.2.0'     => { "pmtacceptance/mysql" => ">=0.6.1 <1.0.0", "pmtacceptance/stdlib" => ">= 2.5.0" },
            '2.2.0-rc1' => { "pmtacceptance/mysql" => ">=0.6.1 <1.0.0", "pmtacceptance/stdlib" => ">= 2.5.0" },
            '2.1.0'     => { "pmtacceptance/mysql" => ">=0.6.1 <1.0.0", "pmtacceptance/stdlib" => ">= 2.5.0" },
            '2.0.0'     => { "pmtacceptance/mysql" => ">= 0.6.1" },
            '1.2.0'     => { "pmtacceptance/mysql" => ">= 0.5.0" },
            '1.1.1'     => { "pmtacceptance/mysql" => ">= 0.5.0" },
            '1.1.0'     => { "pmtacceptance/mysql" => ">= 0.5.0" },
            '1.0.1'     => { "pmtacceptance/mysql" => ">= 0.5.0" },
            '1.0.0'     => { "pmtacceptance/mysql" => ">= 0.5.0" },
            '0.2.0'     => { "pmtacceptance/mysql" => ">= 0.5.0" },
            '0.1.0'     => { "pmtacceptance/mysql" => ">= 0.3.0" },
          },
          'pmtacceptance-mysql' => {
            "2.1.0"     => { "pmtacceptance/stdlib" => ">= 2.2.1" },
            "2.0.1"     => { "pmtacceptance/stdlib" => ">= 2.2.1" },
            "2.0.0"     => { "pmtacceptance/stdlib" => ">= 2.2.1" },
            "2.0.0-rc5" => { "pmtacceptance/stdlib" => ">= 2.2.1" },
            "2.0.0-rc4" => { "pmtacceptance/stdlib" => ">= 2.2.1" },
            "2.0.0-rc3" => { "pmtacceptance/stdlib" => ">= 2.2.1" },
            "2.0.0-rc2" => { "pmtacceptance/stdlib" => ">= 2.2.1" },
            "2.0.0-rc1" => { "pmtacceptance/stdlib" => ">= 2.2.1" },
            "1.0.0"     => { "pmtacceptance/stdlib" => ">= 2.2.1" },
            "0.9.0"     => { "pmtacceptance/stdlib" => ">= 2.2.1" },
            "0.8.1"     => { "pmtacceptance/stdlib" => ">= 2.2.1" },
            "0.8.0"     => { "pmtacceptance/stdlib" => ">= 2.2.1" },
            "0.7.1"     => { "pmtacceptance/stdlib" => ">= 2.2.1" },
            "0.7.0"     => { "pmtacceptance/stdlib" => ">= 2.2.1" },
            "0.6.1"     => { "pmtacceptance/stdlib" => ">= 2.2.1" },
            "0.6.0"     => { "pmtacceptance/stdlib" => ">= 2.2.1" },
            "0.5.0"     => { "pmtacceptance/stdlib" => ">= 2.2.1" },
            "0.4.0"     => {},
            "0.3.0"     => {},
            "0.2.0"     => {},
          },
          'pmtacceptance-apache' => {
            "0.10.0"    => { "pmtacceptance/stdlib" => ">= 2.4.0" },
            "0.9.0"     => { "pmtacceptance/stdlib" => ">= 2.4.0" },
            "0.8.1"     => { "pmtacceptance/stdlib" => ">= 2.2.1" },
            "0.8.0"     => { "pmtacceptance/stdlib" => ">= 2.2.1" },
            "0.7.0"     => { "pmtacceptance/stdlib" => ">= 2.2.1" },
            "0.6.0"     => { "pmtacceptance/stdlib" => ">= 2.2.1" },
            "0.5.0-rc1" => { "pmtacceptance/stdlib" => ">= 2.2.1" },
            "0.4.0"     => { "pmtacceptance/stdlib" => ">= 2.2.1" },
            "0.3.0"     => { "pmtacceptance/stdlib" => ">= 2.2.1" },
            "0.2.2"     => { "pmtacceptance/stdlib" => ">= 2.2.1" },
            "0.2.1"     => { "pmtacceptance/stdlib" => ">= 2.2.1" },
            "0.2.0"     => { "pmtacceptance/stdlib" => ">= 2.2.1" },
            "0.1.1"     => { "pmtacceptance/stdlib" => ">= 2.2.1" },
            "0.0.4"     => {},
            "0.0.3"     => {},
            "0.0.2"     => {},
            "0.0.1"     => {},
          },
          'pmtacceptance-bacula' => {
            "0.0.3" => { "pmtacceptance/stdlib" => ">= 2.2.0", "pmtacceptance/mysql" => ">= 1.0.0" },
            "0.0.2" => { "pmtacceptance/stdlib" => ">= 2.2.0", "pmtacceptance/mysql" => ">= 0.0.1" },
            "0.0.1" => { "pmtacceptance/stdlib" => ">= 2.2.0" },
          },
          'puppetlabs-oneversion' => {
            "0.0.1" => {}
          }
        }

        @available_releases.each do |name, versions|
          versions.each do |version, deps|
            deps, metadata = deps.partition { |k,v| k.is_a? String }
            dependencies = Hash[deps.map { |k, v| [ k.tr('/', '-'), v ] }]

            versions[version] = create_release(name, version, dependencies).tap do |release|
              release.meta_def(:prepare)     { }
              release.meta_def(:install)     { |x| @install_dir = x.to_s }
              release.meta_def(:install_dir) { @install_dir }
              release.meta_def(:metadata) do
                metadata = Hash[metadata].merge(
                  :name         => name,
                  :version      => version,
                  :source       => '',   # GRR, Puppet!
                  :author       => '',   # GRR, Puppet!
                  :license      => '',   # GRR, Puppet!
                  :dependencies => dependencies.map do |dep, range|
                    { :name => dep, :version_requirement => range }
                  end
                )
                Hash[metadata.map { |k,v| [ k.to_s, v ] }]
              end
            end
          end
        end
      end
    end
  end
end