github.com/misseven0/notify@v0.0.0-20230519123055-c1422e46da05/event_test.go (about) 1 // Copyright (c) 2014-2015 The Notify Authors. All rights reserved. 2 // Use of this source code is governed by the MIT license that can be 3 // found in the LICENSE file. 4 5 package notify 6 7 import ( 8 "sort" 9 "strings" 10 "testing" 11 ) 12 13 // S is a workaround for random event strings concatenation order. 14 func s(s string) string { 15 z := strings.Split(s, "|") 16 sort.StringSlice(z).Sort() 17 return strings.Join(z, "|") 18 } 19 20 // This test is not safe to run in parallel with others. 21 func TestEventString(t *testing.T) { 22 cases := map[Event]string{ 23 Create: "notify.Create", 24 Create | Remove: "notify.Create|notify.Remove", 25 Create | Remove | Write: "notify.Create|notify.Remove|notify.Write", 26 Create | Write | Rename: "notify.Create|notify.Rename|notify.Write", 27 } 28 for e, str := range cases { 29 if s := s(e.String()); s != str { 30 t.Errorf("want s=%s; got %s (e=%#x)", str, s, e) 31 } 32 } 33 }