github.com/ranjib/nomad@v0.1.1-0.20160225204057-97751b02f70b/nomad/watch/watch_test.go (about) 1 package watch 2 3 import ( 4 "testing" 5 ) 6 7 func TestWatchItems(t *testing.T) { 8 // Creates an empty set of items 9 wi := NewItems() 10 if len(wi) != 0 { 11 t.Fatalf("expect 0 items, got: %#v", wi) 12 } 13 14 // Creates a new set of supplied items 15 wi = NewItems(Item{Table: "foo"}) 16 if len(wi) != 1 { 17 t.Fatalf("expected 1 item, got: %#v", wi) 18 } 19 20 // Adding items works 21 wi.Add(Item{Node: "bar"}) 22 if len(wi) != 2 { 23 t.Fatalf("expected 2 items, got: %#v", wi) 24 } 25 26 // Adding duplicates auto-dedupes 27 wi.Add(Item{Table: "foo"}) 28 if len(wi) != 2 { 29 t.Fatalf("expected 2 items, got: %#v", wi) 30 } 31 }