From 38ee83e45b4de7edf89bf9f0ef629eb4c6ad0fa8 Mon Sep 17 00:00:00 2001 From: Christopher Speller Date: Thu, 12 May 2016 23:56:07 -0400 Subject: Moving to glide --- .../github.com/mattermost/rsc/plist/plist_test.go | 110 +++++++++++++++++++++ 1 file changed, 110 insertions(+) create mode 100644 vendor/github.com/mattermost/rsc/plist/plist_test.go (limited to 'vendor/github.com/mattermost/rsc/plist/plist_test.go') diff --git a/vendor/github.com/mattermost/rsc/plist/plist_test.go b/vendor/github.com/mattermost/rsc/plist/plist_test.go new file mode 100644 index 000000000..42f496c67 --- /dev/null +++ b/vendor/github.com/mattermost/rsc/plist/plist_test.go @@ -0,0 +1,110 @@ +// Copyright 2012 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package plist + +import ( + "reflect" + "testing" +) + +var thePlist = ` + + BucketUUID + C218A47D-DAFB-4476-9C67-597E556D7D8A + BucketName + rsc + ComputerUUID + E7859547-BB9C-41C0-871E-858A0526BAE7 + LocalPath + /Users/rsc + LocalMountPoint + /Users + IgnoredRelativePaths + + /.Trash + /go/pkg + /go1/pkg + /Library/Caches + + Excludes + + excludes + + + type + 2 + text + .unison. + + + + + +` + +var plistTests = []struct { + in string + out interface{} +}{ + { + thePlist, + &MyStruct{ + BucketUUID: "C218A47D-DAFB-4476-9C67-597E556D7D8A", + BucketName: "rsc", + ComputerUUID: "E7859547-BB9C-41C0-871E-858A0526BAE7", + LocalPath: "/Users/rsc", + LocalMountPoint: "/Users", + IgnoredRelativePaths: []string{ + "/.Trash", + "/go/pkg", + "/go1/pkg", + "/Library/Caches", + }, + Excludes: Exclude1{ + Excludes: []Exclude2{ + {Type: 2, + Text: ".unison.", + }, + }, + }, + }, + }, + { + thePlist, + &struct{}{}, + }, +} + +type MyStruct struct { + BucketUUID string + BucketName string + ComputerUUID string + LocalPath string + LocalMountPoint string + IgnoredRelativePaths []string + Excludes Exclude1 +} + +type Exclude1 struct { + Excludes []Exclude2 `plist:"excludes"` +} + +type Exclude2 struct { + Type int `plist:"type"` + Text string `plist:"text"` +} + +func TestUnmarshal(t *testing.T) { + for _, tt := range plistTests { + v := reflect.New(reflect.ValueOf(tt.out).Type().Elem()).Interface() + if err := Unmarshal([]byte(tt.in), v); err != nil { + t.Errorf("%s", err) + continue + } + if !reflect.DeepEqual(tt.out, v) { + t.Errorf("unmarshal not equal") + } + } +} -- cgit v1.2.3-1-g7c22