func TestObjectIDBufferedChan_slow_reader(t *testing.T) {
	errors := make(chan error, 10)
	send, recv := NewObjectIDBufferedChan("/tmp/repospanner_oidbufferedchan.test", errors)
	var expectedValues []storage.ObjectID
	go func() {
		for i := 0; i < 10042; i++ {
			value := storage.ObjectID(fmt.Sprintf("%d", i))
			send <- value
			expectedValues = append(expectedValues, value)
		}
		close(send)
	}()
	var values []storage.ObjectID
	done := make(chan int)
	go func() {
		for value := range recv {
			values = append(values, value)
			time.Sleep(time.Microsecond)
		}
		close(done)
	}()
	<-done
	if !reflect.DeepEqual(values, expectedValues) {
		t.Fatalf("Wrong value received. Expected %#v, but received %#v", expectedValues, values)
	}
	if len(errors) != 0 {
		t.Fatalf("There was an error in the errors chan")
	}
}
Test with a fast writer and a slow reader. The writer sends enough
objects to require several files to be written, and the reader sleeps
to simulate a slow read.
package service
import (
	"fmt"
	"reflect"
	"testing"
	"time"
	"github.com/repoSpanner/repoSpanner/server/storage"
)
func TestObjectIDBufferedChan_dne(t *testing.T) {
	errors := make(chan error, 10)
	send, recv := NewObjectIDBufferedChan("/doesnotexist/repospanner_oidbufferedchan.test", errors)
	send <- "test"
	close(send)
	var values []storage.ObjectID
	for value := range recv {
		values = append(values, value)
	}
	if len(values) != 0 {
		t.Fatalf("Wrong value received. Expected [], but received %s", values)
	}
	if len(errors) != 1 {
		t.Fatalf("Expected exactly 1 error, but there were %d errors instead", len(errors))
	}
	err := <-errors
	if err.Error() != "open /doesnotexist/repospanner_oidbufferedchan.test: no such file or directory" {
		t.Fatalf("Incorrect error message: %s", err.Error())
	}
	if len(send) != 1 {
		t.Fatalf("write() should have halted but it continued")
	}
}
func TestObjectIDBufferedChan_one_objectid(t *testing.T) {
	errors := make(chan error, 10)
	send, recv := NewObjectIDBufferedChan("/tmp/repospanner_oidbufferedchan.test", errors)
	send <- "test"
	close(send)
	var values []storage.ObjectID
	for value := range recv {
		values = append(values, value)
	}
	if !reflect.DeepEqual(values, []storage.ObjectID{"test"}) {
		t.Fatalf("Wrong value received. Expected {\"test\"}, but received %s", values)
	}
	if len(errors) != 0 {
		t.Fatalf("There was an error in the errors chan")
	}
}