Exemplo n.º 1
0
func (handler *DatasetHandler) Index(w http.ResponseWriter, r *http.Request, _ httprouter.Params) {
	puaro.HTTPLogger(r)

	storage := handler.Storage
	datasets := storage.Datasets()

	res, err := puaro.BuildResponse(datasets)
	if err != nil {
		w.WriteHeader(400)
		fmt.Fprint(w, err)
		return
	}

	fmt.Fprint(w, res)
}
Exemplo n.º 2
0
func TestStorage_Datasets(t *testing.T) {
	bucket, _ := redis.NewBucket(config)

	dataset1 := storage.NewDataset("posts", bucket)
	dataset2 := storage.NewDataset("users", bucket)

	storage := storage.New(bucket)
	storage.Clean()

	storage.Insert(dataset1)
	storage.Insert(dataset2)

	datasets := storage.Datasets()

	if len(datasets) != 2 {
		t.Errorf("Want 2 got %d\n", len(datasets))
	}
}