1// Licensed to Elasticsearch B.V. under one or more contributor 2// license agreements. See the NOTICE file distributed with 3// this work for additional information regarding copyright 4// ownership. Elasticsearch B.V. licenses this file to you under 5// the Apache License, Version 2.0 (the "License"); you may 6// not use this file except in compliance with the License. 7// You may obtain a copy of the License at 8// 9// http://www.apache.org/licenses/LICENSE-2.0 10// 11// Unless required by applicable law or agreed to in writing, 12// software distributed under the License is distributed on an 13// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14// KIND, either express or implied. See the License for the 15// specific language governing permissions and limitations 16// under the License. 17 18package darwin 19 20import ( 21 "testing" 22 23 "github.com/stretchr/testify/assert" 24) 25 26const SystemVersionPlist = `<?xml version="1.0" encoding="UTF-8"?> 27<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> 28<plist version="1.0"> 29<dict> 30 <key>ProductBuildVersion</key> 31 <string>16G1114</string> 32 <key>ProductCopyright</key> 33 <string>1983-2017 Apple Inc.</string> 34 <key>ProductName</key> 35 <string>Mac OS X</string> 36 <key>ProductUserVisibleVersion</key> 37 <string>10.12.6</string> 38 <key>ProductVersion</key> 39 <string>10.12.6</string> 40</dict> 41</plist> 42` 43 44func TestOperatingSystem(t *testing.T) { 45 osInfo, err := getOSInfo([]byte(SystemVersionPlist)) 46 if err != nil { 47 t.Fatal(err) 48 } 49 50 assert.Equal(t, "darwin", osInfo.Family) 51 assert.Equal(t, "darwin", osInfo.Platform) 52 assert.Equal(t, "Mac OS X", osInfo.Name) 53 assert.Equal(t, "10.12.6", osInfo.Version) 54 assert.Equal(t, 10, osInfo.Major) 55 assert.Equal(t, 12, osInfo.Minor) 56 assert.Equal(t, 6, osInfo.Patch) 57 assert.Equal(t, "16G1114", osInfo.Build) 58} 59