github.com/keybase/client/go@v0.0.0-20240309051027-028f7c731f8b/install/fuse_status_darwin_test.go (about) 1 // Copyright 2015 Keybase, Inc. All rights reserved. Use of 2 // this source code is governed by the included BSD license. 3 4 //go:build darwin 5 // +build darwin 6 7 package install 8 9 import ( 10 "testing" 11 12 "github.com/stretchr/testify/assert" 13 ) 14 15 func TestFindStringInPlist(t *testing.T) { 16 const plistTestData = `<?xml version="1.0" encoding="UTF-8"?> 17 <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> 18 <plist version="1.0"> 19 <dict> 20 <key>CFBundleName</key> 21 <string>Keybase</string> 22 <key>CFBundleVersion</key> 23 <string>1.0.17-20160825110028+67f6e3b</string> 24 <key>NSMainNibFile</key> 25 <string>MainMenu</string> 26 </dict> 27 </plist>` 28 version := findStringInPlist("CFBundleVersion", []byte(plistTestData), testLog) 29 assert.Equal(t, "1.0.17-20160825110028+67f6e3b", version) 30 } 31 32 func TestFindStringInPlistWithWhitespace(t *testing.T) { 33 const plistTestData = ` <key> test </key>` + "\n\n \t" + ` <string> value </string> ` + "\n\t" 34 value := findStringInPlist(" test ", []byte(plistTestData), testLog) 35 assert.Equal(t, " value ", value) 36 } 37 38 func TestFindStringInPlistWithNoWhitespace(t *testing.T) { 39 const plistTestData = `<key>test</key><string>value</string>` 40 value := findStringInPlist("test", []byte(plistTestData), testLog) 41 assert.Equal(t, "value", value) 42 }