2016-08-18 22:11:42 +03:00
|
|
|
require "test_helper"
|
|
|
|
|
|
|
|
describe Plist do
|
|
|
|
it "parses some hdiutil output okay" do
|
2016-08-24 00:41:50 +02:00
|
|
|
hdiutil_output = <<-EOS.undent
|
|
|
|
<?xml version="1.0" encoding="UTF-8"?>
|
|
|
|
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
|
|
<plist version="1.0">
|
|
|
|
<dict>
|
|
|
|
<key>system-entities</key>
|
|
|
|
<array>
|
|
|
|
<dict>
|
|
|
|
<key>content-hint</key>
|
|
|
|
<string>Apple_partition_map</string>
|
|
|
|
<key>dev-entry</key>
|
|
|
|
<string>/dev/disk3s1</string>
|
|
|
|
<key>potentially-mountable</key>
|
|
|
|
<false/>
|
|
|
|
<key>unmapped-content-hint</key>
|
|
|
|
<string>Apple_partition_map</string>
|
|
|
|
</dict>
|
|
|
|
<dict>
|
|
|
|
<key>content-hint</key>
|
|
|
|
<string>Apple_partition_scheme</string>
|
|
|
|
<key>dev-entry</key>
|
|
|
|
<string>/dev/disk3</string>
|
|
|
|
<key>potentially-mountable</key>
|
|
|
|
<false/>
|
|
|
|
<key>unmapped-content-hint</key>
|
|
|
|
<string>Apple_partition_scheme</string>
|
|
|
|
</dict>
|
|
|
|
<dict>
|
|
|
|
<key>content-hint</key>
|
|
|
|
<string>Apple_HFS</string>
|
|
|
|
<key>dev-entry</key>
|
|
|
|
<string>/dev/disk3s2</string>
|
|
|
|
<key>mount-point</key>
|
|
|
|
<string>/private/tmp/dmg.BhfS2g</string>
|
|
|
|
<key>potentially-mountable</key>
|
|
|
|
<true/>
|
|
|
|
<key>unmapped-content-hint</key>
|
|
|
|
<string>Apple_HFS</string>
|
|
|
|
<key>volume-kind</key>
|
|
|
|
<string>hfs</string>
|
|
|
|
</dict>
|
|
|
|
</array>
|
|
|
|
</dict>
|
|
|
|
</plist>
|
|
|
|
EOS
|
2016-08-18 22:11:42 +03:00
|
|
|
|
|
|
|
parsed = Plist.parse_xml(hdiutil_output)
|
|
|
|
|
|
|
|
parsed.keys.must_equal ["system-entities"]
|
|
|
|
parsed["system-entities"].length.must_equal 3
|
|
|
|
parsed["system-entities"].map { |e| e["dev-entry"] }.must_equal %w[
|
2016-10-14 20:33:16 +02:00
|
|
|
/dev/disk3s1
|
|
|
|
/dev/disk3
|
|
|
|
/dev/disk3s2
|
|
|
|
]
|
2016-08-18 22:11:42 +03:00
|
|
|
end
|
|
|
|
|
|
|
|
it "does not choke on empty input" do
|
|
|
|
Plist.parse_xml("").must_equal {}
|
|
|
|
end
|
|
|
|
end
|