本文整理匯總了Golang中github.com/ninnemana/API/models/products.Part.Content方法的典型用法代碼示例。如果您正苦於以下問題:Golang Part.Content方法的具體用法?Golang Part.Content怎麽用?Golang Part.Content使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/ninnemana/API/models/products.Part
的用法示例。
在下文中一共展示了Part.Content方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: TestParts
func TestParts(t *testing.T) {
var err error
var p products.Part
p.ID = 10999 //set part number here for use in creating related objects
var price products.Price
// var cu customer.CustomerUser
var cat products.Category
cat.Create()
//create install sheet content type
var contentType custcontent.ContentType
contentType.Type = "InstallationSheet"
err = contentType.Create()
//create install sheet content
var installSheetContent products.Content
installSheetContent.Text = "https://www.curtmfg.com/masterlibrary/13201/installsheet/CM_13201_INS.PDF"
installSheetContent.ContentType.Id = contentType.Id
err = installSheetContent.Create()
//create video type -- used in creating video during video test
var vt video.VideoType
vt.Name = "test type"
vt.Create()
//key types
var pub, pri, auth apiKeyType.ApiKeyType
if database.GetCleanDBFlag() != "" {
//setup apiKeyTypes
pub.Type = "public"
pri.Type = "private"
auth.Type = "authentication"
pub.Create()
pri.Create()
auth.Create()
}
dtx, err := apicontextmock.Mock()
if err != nil {
t.Log(err)
}
Convey("TestingParts", t, func() {
//test create part
p.Categories = append(p.Categories, cat)
p.OldPartNumber = "8675309"
p.ShortDesc = "test part"
p.Content = append(p.Content, installSheetContent)
bodyBytes, _ := json.Marshal(p)
bodyJson := bytes.NewReader(bodyBytes)
thyme := time.Now()
testThatHttp.RequestWithDtx("post", "/part", "", "?key="+dtx.APIKey, CreatePart, bodyJson, "application/json", dtx)
So(time.Since(thyme).Nanoseconds(), ShouldBeLessThan, time.Second.Nanoseconds()/2)
So(testThatHttp.Response.Code, ShouldEqual, 200)
err = json.Unmarshal(testThatHttp.Response.Body.Bytes(), &p)
So(err, ShouldBeNil)
So(p, ShouldHaveSameTypeAs, products.Part{})
So(p.ID, ShouldEqual, 10999)
p.BindCustomer(dtx)
var custPrice customer.Price
custPrice.CustID = dtx.CustomerID
custPrice.PartID = p.ID
err = custPrice.Create()
//test create price
price.Price = 987
price.PartId = p.ID
price.Type = "test"
bodyBytes, _ = json.Marshal(price)
bodyJson = bytes.NewReader(bodyBytes)
thyme = time.Now()
testThatHttp.RequestWithDtx("post", "/price", "", "?key="+dtx.APIKey, SavePrice, bodyJson, "application/json", dtx)
So(time.Since(thyme).Nanoseconds(), ShouldBeLessThan, time.Second.Nanoseconds()/2)
So(testThatHttp.Response.Code, ShouldEqual, 200)
err = json.Unmarshal(testThatHttp.Response.Body.Bytes(), &price)
So(err, ShouldBeNil)
So(price, ShouldHaveSameTypeAs, products.Price{})
So(price.Id, ShouldBeGreaterThan, 0)
//test update price
price.Type = "tester"
bodyBytes, _ = json.Marshal(price)
bodyJson = bytes.NewReader(bodyBytes)
thyme = time.Now()
testThatHttp.RequestWithDtx("post", "/price/", ":id", strconv.Itoa(price.Id)+"?key="+dtx.APIKey, SavePrice, bodyJson, "application/json", dtx)
So(time.Since(thyme).Nanoseconds(), ShouldBeLessThan, time.Second.Nanoseconds()/2)
So(testThatHttp.Response.Code, ShouldEqual, 200)
err = json.Unmarshal(testThatHttp.Response.Body.Bytes(), &price)
So(err, ShouldBeNil)
So(price, ShouldHaveSameTypeAs, products.Price{})
So(price.Type, ShouldNotEqual, "test")
// //test get part prices
thyme = time.Now()
testThatHttp.RequestWithDtx("get", "/part/", ":part/prices", strconv.Itoa(p.ID)+"/prices?key="+dtx.APIKey, Prices, nil, "", dtx)
So(time.Since(thyme).Nanoseconds(), ShouldBeLessThan, time.Second.Nanoseconds()/2)
So(testThatHttp.Response.Code, ShouldEqual, 200)
//.........這裏部分代碼省略.........