File tree Expand file tree Collapse file tree 2 files changed +22
-32
lines changed Expand file tree Collapse file tree 2 files changed +22
-32
lines changed Original file line number Diff line number Diff line change 171
171
end
172
172
end
173
173
end
174
-
175
- describe "#without_env internal helper with UTF8 characters" do
176
- let ( :varname ) { "\u16A0 \u16C7 \u16BB \u16EB \u16D2 \u16E6 \u16A6 \u16EB \u16A0 \u16B1 \u16A9 \u16A0 \u16A2 \u16B1 \u16EB \u16A0 \u16C1 \u16B1 \u16AA \u16EB \u16B7 \u16D6 \u16BB \u16B9 \u16E6 \u16DA \u16B3 \u16A2 \u16D7 " }
177
- let ( :rune_utf8 ) { "\u16A0 \u16C7 \u16BB \u16EB \u16D2 \u16E6 \u16A6 \u16EB \u16A0 \u16B1 \u16A9 \u16A0 \u16A2 \u16B1 \u16EB \u16A0 \u16C1 \u16B1 \u16AA \u16EB \u16B7 \u16D6 \u16BB \u16B9 \u16E6 \u16DA \u16B3 \u16A2 \u16D7 " }
178
-
179
- before do
180
- Puppet ::Util ::Windows ::Process . set_environment_variable ( varname , rune_utf8 )
181
- end
182
-
183
- it "removes environment variables within the block with UTF8 name" do
184
- without_env ( varname ) do
185
- expect ( ENV [ varname ] ) . to be ( nil )
186
- end
187
- end
188
-
189
- it "restores UTF8 characters in environment variable values" do
190
- without_env ( varname ) do
191
- Puppet ::Util ::Windows ::Process . set_environment_variable ( varname , 'bad value' )
192
- end
193
-
194
- envhash = Puppet ::Util ::Windows ::Process . get_environment_strings
195
- expect ( envhash [ varname ] ) . to eq ( rune_utf8 )
196
- end
197
- end
198
174
end
199
175
200
176
def as_root
@@ -206,12 +182,4 @@ def as_non_root
206
182
allow ( Puppet . features ) . to receive ( :root? ) . and_return ( false )
207
183
yield
208
184
end
209
-
210
- def without_env ( name , &block )
211
- saved = Puppet ::Util . get_env ( name )
212
- Puppet ::Util . set_env ( name , nil )
213
- yield
214
- ensure
215
- Puppet ::Util . set_env ( name , saved )
216
- end
217
185
end
Original file line number Diff line number Diff line change @@ -65,6 +65,28 @@ def get_mode(file)
65
65
end
66
66
expect ( ENV [ "FOO" ] ) . to eq ( nil )
67
67
end
68
+ it "accepts a unicode key" do
69
+ key = "\u16A0 \u16C7 \u16BB \u16EB \u16D2 \u16E6 \u16A6 \u16EB \u16A0 \u16B1 \u16A9 \u16A0 \u16A2 \u16B1 \u16EB \u16A0 \u16C1 \u16B1 \u16AA \u16EB \u16B7 \u16D6 \u16BB \u16B9 \u16E6 \u16DA \u16B3 \u16A2 \u16D7 "
70
+
71
+ Puppet ::Util . withenv ( key => "bar" ) do
72
+ expect ( ENV [ key ] ) . to eq ( "bar" )
73
+ end
74
+ end
75
+
76
+ it "accepts a unicode value" do
77
+ value = "\u16A0 \u16C7 \u16BB \u16EB \u16D2 \u16E6 \u16A6 \u16EB \u16A0 \u16B1 \u16A9 \u16A0 \u16A2 \u16B1 \u16EB \u16A0 \u16C1 \u16B1 \u16AA \u16EB \u16B7 \u16D6 \u16BB \u16B9 \u16E6 \u16DA \u16B3 \u16A2 \u16D7 "
78
+
79
+ Puppet ::Util . withenv ( "runes" => value ) do
80
+ expect ( ENV [ "runes" ] ) . to eq ( value )
81
+ end
82
+ end
83
+
84
+ it "accepts a nil value" do
85
+ Puppet ::Util . withenv ( "foo" => nil ) do
86
+ expect ( ENV [ "foo" ] ) . to eq ( nil )
87
+ end
88
+ end
89
+
68
90
end
69
91
70
92
describe "#withenv on POSIX" , :unless => Puppet ::Util ::Platform . windows? do
You can’t perform that action at this time.
0 commit comments