2 Module: Test_Puppetfile
3 Provides unit tests and examples for the <Puppetfile> lens.
5 module Test_Puppetfile =
7 (* Test: Puppetfile.lns *)
8 test Puppetfile.lns get "forge \"https://forgeapi.puppetlabs.com\" # the default forge
10 mod 'puppetlabs-razor'
11 mod 'puppetlabs-ntp', \"0.0.3\"
14 :git => \"git://github.com/puppetlabs/puppetlabs-apt.git\"
16 mod 'puppetlabs-stdlib',
17 :git => \"git://github.com/puppetlabs/puppetlabs-stdlib.git\"
19 mod 'puppetlabs-apache', '0.6.0',
20 :github_tarball => 'puppetlabs/puppetlabs-apache'
22 metadata # we want metadata\n" =
23 { "forge" = "https://forgeapi.puppetlabs.com"
24 { "#comment" = "the default forge" } }
26 { "1" = "puppetlabs-razor" }
27 { "2" = "puppetlabs-ntp"
28 { "@version" = "0.0.3" }
31 { "3" = "puppetlabs-apt"
32 { "git" = "git://github.com/puppetlabs/puppetlabs-apt.git" }
35 { "4" = "puppetlabs-stdlib"
36 { "git" = "git://github.com/puppetlabs/puppetlabs-stdlib.git" }
39 { "5" = "puppetlabs-apache"
40 { "@version" = "0.6.0" }
41 { "github_tarball" = "puppetlabs/puppetlabs-apache" }
44 { "metadata" { "#comment" = "we want metadata" } }
46 (* Test: Puppetfile.lns
47 Complex version conditions *)
48 test Puppetfile.lns get "mod 'puppetlabs/stdlib', '< 5.0.0'
49 mod 'theforeman/concat_native', '>= 1.3.0 < 1.4.0'
50 mod 'herculesteam/augeasproviders', '2.1.x'\n" =
51 { "1" = "puppetlabs/stdlib"
52 { "@version" = "< 5.0.0" }
54 { "2" = "theforeman/concat_native"
55 { "@version" = ">= 1.3.0 < 1.4.0" }
57 { "3" = "herculesteam/augeasproviders"
58 { "@version" = "2.1.x" }
61 (* Test: Puppetfile.lns
62 Owner is not mandatory if git is given *)
63 test Puppetfile.lns get "mod 'stdlib',
64 :git => \"git://github.com/puppetlabs/puppetlabs-stdlib.git\"\n" =
66 { "git" = "git://github.com/puppetlabs/puppetlabs-stdlib.git" } }
70 test Puppetfile.lns get "mod 'puppetlabs/apache', :latest\n" =
71 { "1" = "puppetlabs/apache"
74 test Puppetfile.lns get "mod 'data',
75 :git => 'ssh://git@stash.example.com/bp/puppet-hiera.git',
76 :branch => :control_branch,
77 :default_branch => 'development',
78 :install_path => '.'\n" =
80 { "git" = "ssh://git@stash.example.com/bp/puppet-hiera.git" }
81 { "branch" = ":control_branch" }
82 { "default_branch" = "development" }
83 { "install_path" = "." } }
85 (* Comment: after module name comma
86 This conflicts with the comma comment tree below *)
87 test Puppetfile.lns get "mod 'data' # eol comment\n" = *
89 (* Comment: after first comma *)
90 test Puppetfile.lns get "mod 'data', # eol comment
94 { "#comment" = "eol comment" }
95 { "#comment" = "and another" }
96 { "@version" = "1.2.3" } }
98 (* Comment: after version
99 Current culprit: need two \n *)
100 test Puppetfile.lns get "mod 'data', '1.2.3' # eol comment\n" = *
101 test Puppetfile.lns get "mod 'data', '1.2.3' # eol comment\n\n" =
103 { "@version" = "1.2.3" { "#comment" = "eol comment" } } }
105 (* Comment: eol after version comma *)
106 test Puppetfile.lns get "mod 'data', '1.2.3', # a comment
109 { "@version" = "1.2.3" }
110 { "#comment" = "a comment" }
111 { "local" = "true" } }
113 (* Comment: after version comma with newline *)
114 test Puppetfile.lns get "mod 'data', '1.2.3',
118 { "@version" = "1.2.3" }
119 { "#comment" = "a comment" }
120 { "local" = "true" } }
122 (* Comment: eol before opts, without version *)
123 test Puppetfile.lns get "mod 'data', # a comment
127 { "#comment" = "a comment" }
128 { "#comment" = ":ref => 'abcdef'," }
129 { "local" = "true" } }
131 (* Comment: after opt comma *)
132 test Puppetfile.lns get "mod 'data', '1.2.3',
133 :ref => 'abcdef', # eol comment
136 { "@version" = "1.2.3" }
138 { "#comment" = "eol comment" }
139 { "local" = "true" } }
141 (* Comment: in opts *)
142 test Puppetfile.lns get "mod 'data', '1.2.3',
147 { "@version" = "1.2.3" }
149 { "#comment" = "a comment" }
150 { "local" = "true" } }
152 (* Comment: after last opt *)
153 test Puppetfile.lns get "mod 'data', '1.2.3',
154 :local => true # eol comment\n\n" =
156 { "@version" = "1.2.3" }
158 { "#comment" = "eol comment" } }