Exemplo n.º 1
0
func FindAll(query bson.M) (r []*Product, err error) {
	err = mgodb.FindAll(PRODUCTS, query, &r)
	return
}
Exemplo n.º 2
0
func FindAll(query bson.M) (review []*Review, err error) {
	err = mgodb.FindAll(REVIEWS, query, &review)
	return
}
Exemplo n.º 3
0
func FindAll(query bson.M) (efficacies []*Efficacy, err error) {
	err = mgodb.FindAll(EFFICACIES, query, &efficacies)
	return
}
Exemplo n.º 4
0
func FindAll(query bson.M) (categories []*Category, err error) {
	err = mgodb.FindAll(CATEGORIES, query, &categories)
	return
}
Exemplo n.º 5
0
func FindAll(query bson.M) (r []*Note, err error) {
	err = mgodb.FindAll(NOTES, query, &r)
	return
}
Exemplo n.º 6
0
func TestThumbnailLoader(t *testing.T) {

	mgodb.Setup("localhost", "tenpu_test")
	mgodb.DropCollections(collectionName, thumbnailsCollectionName)

	m := &maker{}
	_, meta, _, _ := m.MakeForUpload(nil)

	http.HandleFunc("/thumbpostupload", tenpu.MakeUploader(m))
	http.HandleFunc("/thumbload", thumbnails.MakeLoader(&thumbnails.Configuration{
		Maker: m,
		ThumbnailStorageMaker: &ThumbnailStorageMaker{},
		ThumbnailSpecs: []*thumbnails.ThumbnailSpec{
			{Name: "icon", Width: 100},
		},
	}))

	ts := httptest.NewServer(http.DefaultServeMux)
	defer ts.Close()

	var err error

	s := integrationtest.NewSession()
	res := integrationtest.Must(s.PostMultipart(ts.URL+"/thumbpostupload", func(w *multipart.Writer) {
		w.WriteField("OwnerId", "my12345")
		p1, err := w.CreateFormFile("t", "t.jpg")
		if err != nil {
			panic(err)
		}
		tf, err1 := os.Open("t.jpg")
		if err1 != nil {
			panic(err1)
		}
		defer tf.Close()

		io.Copy(p1, tf)
	}))

	b, _ := ioutil.ReadAll(res.Body)
	strb := string(b)
	if !strings.Contains(strb, "my12345") {
		t.Errorf("%+v", strb)
	}

	atts := meta.Attachments("my12345")
	if len(atts) != 1 {
		t.Errorf("%+v", atts)
	}

	res, err = http.Get(ts.URL + fmt.Sprintf("/thumbload?id=%s&thumb=icon", atts[0].Id))
	if err != nil {
		panic(err)
	}

	f, err2 := os.OpenFile("thumbGenerated.jpg", os.O_CREATE|os.O_RDWR, 0666)
	if err2 != nil {
		panic(err2)
	}

	defer f.Close()

	io.Copy(f, res.Body)

	http.Get(ts.URL + fmt.Sprintf("/thumbload?id=%s&thumb=icon", atts[0].Id))

	var thumbs []thumbnails.Thumbnail
	mgodb.FindAll(thumbnailsCollectionName, bson.M{}, &thumbs)
	if len(thumbs) != 1 {
		t.Errorf("%+v", thumbs)
	}
}
Exemplo n.º 7
0
func FindAll(query bson.M) (brands []*Brand, err error) {
	err = mgodb.FindAll(BRANDS, query, &brands)
	return
}
Exemplo n.º 8
0
func FindAll(query bson.M) (r []*FollowBrand, err error) {
	err = mgodb.FindAll(FOLLOW_BRANDS, query, &r)
	return
}
Exemplo n.º 9
0
func FindAll(query bson.M) (r []*Post, err error) {
	err = mgodb.FindAll(POSTS, query, &r)
	return
}
Exemplo n.º 10
0
func FindAll(query bson.M) (r []*WishItem, err error) {
	err = mgodb.FindAll(WISH_ITEMS, query, &r)
	return
}
Exemplo n.º 11
0
func FindAll(query bson.M) (r []*News, err error) {
	err = mgodb.FindAll(NEWS, query, &r)
	return
}
Exemplo n.º 12
0
func FindAll(query bson.M) (users []*User, err error) {
	err = mgodb.FindAll(USERS, query, &users)
	return
}