예제 #1
0
func TestAdd(t *testing.T) {
	store := New()
	newItem := item.New(time.Now(), []byte("payload"))
	store.Add(newItem)
	if store.items[0] != newItem {
		t.Fail()
	}
}
예제 #2
0
func TestGet(t *testing.T) {
	store := New()
	newItem := item.New(time.Now(), []byte("payload"))
	store.Add(newItem)
	currentItem, err := store.Get()
	if err != nil {
		t.Fail()
	}
	if currentItem != newItem {
		t.Fail()
	}
}
예제 #3
0
func TestAddFull(t *testing.T) {
	store := New()
	times := 10
	for i := 0; i < times; i++ {
		newItem := item.New(time.Now(), []byte(fmt.Sprintf("%d", i)))
		store.Add(newItem)
		sameItem, err := store.Get()
		if err != nil {
			t.Fail()
		}
		if sameItem != newItem {
			t.Fail()
		}
	}
}
예제 #4
0
파일: service.go 프로젝트: SudoQ/satchel
func (this *Service) Run() {
	dataCh := this.ext.DataChannel()
	defer this.ext.Close()
	go this.ext.Collect()
	go func() {
		for {
			select {
			case payload := <-dataCh:
				newItem := item.New(time.Now(), payload)
				this.Cache.Add(newItem)
			}
		}
	}()

	this.resourceManager.Run()
}