File: event_test.go

package info (click to toggle)
golang-github-syncthing-notify 0.0~git20180806.b76b458-1
  • links: PTS, VCS
  • area: main
  • in suites: buster, sid
  • size: 440 kB
  • sloc: makefile: 3
file content (33 lines) | stat: -rw-r--r-- 903 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
// Copyright (c) 2014-2015 The Notify Authors. All rights reserved.
// Use of this source code is governed by the MIT license that can be
// found in the LICENSE file.

package notify

import (
	"sort"
	"strings"
	"testing"
)

// S is a workaround for random event strings concatenation order.
func s(s string) string {
	z := strings.Split(s, "|")
	sort.StringSlice(z).Sort()
	return strings.Join(z, "|")
}

// This test is not safe to run in parallel with others.
func TestEventString(t *testing.T) {
	cases := map[Event]string{
		Create:                  "notify.Create",
		Create | Remove:         "notify.Create|notify.Remove",
		Create | Remove | Write: "notify.Create|notify.Remove|notify.Write",
		Create | Write | Rename: "notify.Create|notify.Rename|notify.Write",
	}
	for e, str := range cases {
		if s := s(e.String()); s != str {
			t.Errorf("want s=%s; got %s (e=%#x)", str, s, e)
		}
	}
}