Пример #1
0
func checkStat(idx *index.Index, want []blob.SizedRef) error {
	dest := make(chan blob.SizedRef)
	defer close(dest)
	errCh := make(chan error)
	input := make([]blob.Ref, len(want))
	for _, sbr := range want {
		input = append(input, sbr.Ref)
	}
	go func() {
		errCh <- idx.StatBlobs(dest, input)
	}()
	for k, sbr := range want {
		got, ok := <-dest
		if !ok {
			return fmt.Errorf("could not get stat number %d", k)
		}
		if got != sbr {
			return fmt.Errorf("stat %d: got %v, wanted %v", k, got, sbr)
		}
	}
	return <-errCh
}