예제 #1
0
func FindAll(query bson.M) (r []*Product, err error) {
	err = mgodb.FindAll(PRODUCTS, query, &r)
	return
}
예제 #2
0
func FindAll(query bson.M) (review []*Review, err error) {
	err = mgodb.FindAll(REVIEWS, query, &review)
	return
}
예제 #3
0
func FindAll(query bson.M) (efficacies []*Efficacy, err error) {
	err = mgodb.FindAll(EFFICACIES, query, &efficacies)
	return
}
예제 #4
0
func FindAll(query bson.M) (categories []*Category, err error) {
	err = mgodb.FindAll(CATEGORIES, query, &categories)
	return
}
예제 #5
0
파일: note_curd.go 프로젝트: kobeld/duoerl
func FindAll(query bson.M) (r []*Note, err error) {
	err = mgodb.FindAll(NOTES, query, &r)
	return
}
예제 #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)
	}
}
예제 #7
0
파일: brand_curd.go 프로젝트: kobeld/duoerl
func FindAll(query bson.M) (brands []*Brand, err error) {
	err = mgodb.FindAll(BRANDS, query, &brands)
	return
}
예제 #8
0
func FindAll(query bson.M) (r []*FollowBrand, err error) {
	err = mgodb.FindAll(FOLLOW_BRANDS, query, &r)
	return
}
예제 #9
0
파일: post_curd.go 프로젝트: kobeld/duoerl
func FindAll(query bson.M) (r []*Post, err error) {
	err = mgodb.FindAll(POSTS, query, &r)
	return
}
예제 #10
0
func FindAll(query bson.M) (r []*WishItem, err error) {
	err = mgodb.FindAll(WISH_ITEMS, query, &r)
	return
}
예제 #11
0
파일: news_curd.go 프로젝트: kobeld/duoerl
func FindAll(query bson.M) (r []*News, err error) {
	err = mgodb.FindAll(NEWS, query, &r)
	return
}
예제 #12
0
파일: user_curd.go 프로젝트: kobeld/duoerl
func FindAll(query bson.M) (users []*User, err error) {
	err = mgodb.FindAll(USERS, query, &users)
	return
}