本文整理匯總了Golang中github.com/ninnemana/API/models/products.Part.Delete方法的典型用法代碼示例。如果您正苦於以下問題:Golang Part.Delete方法的具體用法?Golang Part.Delete怎麽用?Golang Part.Delete使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/ninnemana/API/models/products.Part
的用法示例。
在下文中一共展示了Part.Delete方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: TestParts
//.........這裏部分代碼省略.........
//test get videos
//create part video
var partVid video.Video
err = partVid.Create(dtx)
err = partVid.CreateJoinPart(p.ID)
thyme = time.Now()
testThatHttp.Request("get", "/part/videos/", ":part", strconv.Itoa(p.ID)+"?key="+dtx.APIKey, Videos, nil, "")
So(time.Since(thyme).Nanoseconds(), ShouldBeLessThan, time.Second.Nanoseconds()/2)
So(testThatHttp.Response.Code, ShouldEqual, 200)
var ps []products.PartVideo
err = json.Unmarshal(testThatHttp.Response.Body.Bytes(), &ps)
So(err, ShouldBeNil)
So(len(ps), ShouldBeGreaterThan, 0)
//get active approved reviews
//create active approved review
var review products.Review
review.PartID = p.ID
review.Rating = 1
review.Active = true
review.Approved = true
err = review.Create(dtx)
thyme = time.Now()
testThatHttp.Request("get", "/part/reviews/", ":part", strconv.Itoa(p.ID)+"?key="+dtx.APIKey, ActiveApprovedReviews, nil, "")
So(time.Since(thyme).Nanoseconds(), ShouldBeLessThan, time.Second.Nanoseconds()/2)
So(testThatHttp.Response.Code, ShouldEqual, 200)
var reviews products.Reviews
err = json.Unmarshal(testThatHttp.Response.Body.Bytes(), &reviews)
So(err, ShouldBeNil)
So(len(reviews), ShouldBeGreaterThan, 0)
review.Delete(dtx) //teardown - part has FK constraint on review.partID
//get packaging - no package created in test
thyme = time.Now()
testThatHttp.Request("get", "/part/packages/", ":part", strconv.Itoa(p.ID)+"?key="+dtx.APIKey, Packaging, nil, "")
So(time.Since(thyme).Nanoseconds(), ShouldBeLessThan, time.Second.Nanoseconds()/2)
So(testThatHttp.Response.Code, ShouldEqual, 200)
var pack []products.Package
err = json.Unmarshal(testThatHttp.Response.Body.Bytes(), &pack)
So(err, ShouldBeNil)
So(pack, ShouldHaveSameTypeAs, []products.Package{})
//get content
thyme = time.Now()
testThatHttp.Request("get", "/part/content/", ":part", strconv.Itoa(p.ID)+"?key="+dtx.APIKey, GetContent, nil, "")
So(time.Since(thyme).Nanoseconds(), ShouldBeLessThan, time.Second.Nanoseconds()/2)
So(testThatHttp.Response.Code, ShouldEqual, 200)
var content products.Content
err = json.Unmarshal(testThatHttp.Response.Body.Bytes(), &content)
So(err, ShouldBeNil)
So(content, ShouldHaveSameTypeAs, products.Content{})
//get attributes
thyme = time.Now()
testThatHttp.Request("get", "/part/attributes/", ":part", strconv.Itoa(p.ID)+"?key="+dtx.APIKey, Attributes, nil, "")
So(time.Since(thyme).Nanoseconds(), ShouldBeLessThan, time.Second.Nanoseconds()/2)
So(testThatHttp.Response.Code, ShouldEqual, 200)
var attributes []products.Attribute
err = json.Unmarshal(testThatHttp.Response.Body.Bytes(), &attributes)
So(err, ShouldBeNil)
So(attributes, ShouldHaveSameTypeAs, []products.Attribute{})
//test get images