當前位置: 首頁>>代碼示例>>Golang>>正文


Golang Customer.Email方法代碼示例

本文整理匯總了Golang中github.com/ninnemana/API/models/cart.Customer.Email方法的典型用法代碼示例。如果您正苦於以下問題:Golang Customer.Email方法的具體用法?Golang Customer.Email怎麽用?Golang Customer.Email使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在github.com/ninnemana/API/models/cart.Customer的用法示例。


在下文中一共展示了Customer.Email方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: Test_EditAccount

func Test_EditAccount(t *testing.T) {

	Convey("with shop identifier", t, func() {
		shopID := cart.InsertTestData()
		So(shopID, ShouldNotBeNil)
		val := shopID.Hex()
		qs := make(url.Values, 0)
		qs.Add("shop", val)

		cust := cart.Customer{
			ShopId:    *shopID,
			FirstName: "Alex",
			LastName:  "Ninneman",
			Email:     time.Now().Format(time.RFC3339Nano) + "@gmail.com",
		}

		cust.Password = "password"
		response = httprunner.JsonRequest("POST", "/shopify/account", &qs, cust, AddAccount)
		So(response.Code, ShouldEqual, 200)
		So(json.Unmarshal(response.Body.Bytes(), &cust), ShouldBeNil)

		cust.Email = time.Now().Format(time.RFC3339Nano) + "@gmail.com"
		header := map[string]interface{}{
			"Authorization": "Bearer as;ldskfja;lfdj",
		}
		response = httprunner.Req(EditAccount, "PUT", "", "/shopify/account", &qs, nil, cust, header)
		So(response.Code, ShouldEqual, 500)
		So(json.Unmarshal(response.Body.Bytes(), &apierror.ApiErr{}), ShouldBeNil)

		header = map[string]interface{}{
			"Authorization": "Bearer " + cust.Token,
		}
		cust.FirstName = ""
		response = httprunner.Req(EditAccount, "PUT", "", "/shopify/account", &qs, nil, cust, header)
		So(response.Code, ShouldEqual, 500)
		So(json.Unmarshal(response.Body.Bytes(), &apierror.ApiErr{}), ShouldBeNil)

		cust.FirstName = "Alex"
		response = httprunner.Req(EditAccount, "PUT", "", "/shopify/account", &qs, nil, cust, header)
		So(response.Code, ShouldEqual, 200)
		So(json.Unmarshal(response.Body.Bytes(), &cust), ShouldBeNil)
	})
}
開發者ID:ninnemana,項目名稱:API,代碼行數:43,代碼來源:account_test.go

示例2: Test_AddAccount

func Test_AddAccount(t *testing.T) {
	Convey("with shop identifier", t, func() {
		shopID := cart.InsertTestData()
		So(shopID, ShouldNotBeNil)
		val := shopID.Hex()
		qs := make(url.Values, 0)
		qs.Add("shop", val)

		response = httprunner.Req(AddAccount, "POST", "", "/shopify/account", &qs, nil, cart.Shop{})
		So(response.Code, ShouldEqual, 500)
		So(json.Unmarshal(response.Body.Bytes(), &apierror.ApiErr{}), ShouldBeNil)

		cust := cart.Customer{
			ShopId:    *shopID,
			FirstName: "Alex",
			LastName:  "Ninneman",
		}

		addr := cart.CustomerAddress{}
		addr.Address1 = "Test"

		response = httprunner.Req(AddAccount, "POST", "", "/shopify/account", &qs, nil, addr)
		So(response.Code, ShouldEqual, 500)
		So(json.Unmarshal(response.Body.Bytes(), &apierror.ApiErr{}), ShouldBeNil)

		response = httprunner.Req(AddAccount, "POST", "", "/shopify/account", &qs, nil, cust)
		So(response.Code, ShouldEqual, 500)
		So(json.Unmarshal(response.Body.Bytes(), &apierror.ApiErr{}), ShouldBeNil)

		cust.Email = time.Now().Format(time.RFC3339Nano) + "@gmail.com"

		response = httprunner.JsonRequest("POST", "/shopify/account", &qs, nil, AddAccount)
		So(response.Code, ShouldEqual, 500)
		So(json.Unmarshal(response.Body.Bytes(), &apierror.ApiErr{}), ShouldBeNil)

		cust.Password = "password"
		response = httprunner.JsonRequest("POST", "/shopify/account", &qs, cust, AddAccount)
		So(response.Code, ShouldEqual, 200)
		So(json.Unmarshal(response.Body.Bytes(), &cust), ShouldBeNil)
	})
}
開發者ID:ninnemana,項目名稱:API,代碼行數:41,代碼來源:account_test.go


注:本文中的github.com/ninnemana/API/models/cart.Customer.Email方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。