Skip to content

v0.1.10

Compare
Choose a tag to compare
@siller174 siller174 released this 09 Jan 09:33
· 59 commits to master since this release
d329f99

New

  1. Support multipart/form-data
    #31
func TestUploadfile(t *testing.T) {
	cute.NewTestBuilder().
		Title("Uploat file").
		Create().
		RequestBuilder(
			cute.WithURI("http://localhost:7000/v1/admin/banner"),
			cute.WithMethod("POST"),
			cute.WithFormKV("body", []byte("{\"age\": 42}")),
			cute.WithFileFormKV("image", &cute.File{
				Path: "/vasya/gogogo.png",
			}),
		).
		ExecuteTest(context.Background(), t)
}
  1. Implement hard validation
    #30
func TestUploadfile(t *testing.T) {
	cute.NewTestBuilder().
		Title("Uploat file").
		Create().
		RequestBuilder(
			cute.WithURI("http://localhost:7000/v1/admin/banner"),
			cute.WithMethod("POST"),
			cute.WithFormKV("body", []byte("{\"age\": 42}")),
			cute.WithFileFormKV("image", &cute.File{
				Path: "/vasya/gogogo.png",
			}),
		).
                EnableHardValidation(). <- enable hard validation
                ExpectStatus(http.StatusOK).
		ExecuteTest(context.Background(), t)
}
  1. Rename asserts
 GreaterThan => LengthGreaterThan
 GreaterOrEqualThan  => LengthGreaterOrEqualThan
 LessThan => LengthLessThan
 LessOrEqualThan => LengthLessOrEqualThan
  1. Implement common after/before test
    #32

func TestName(t *testing.T) {
	testMaker := cute.NewHTTPTestMaker(
		cute.WithMiddlewareAfterT(modules.LogTraceID),
	)
}

func LogTraceID(t cute.T, response *http.Response, errors []error) error {
	t.Logf("[o3_request_info] Trace_id - %v", response.Header.Get("x-trace-id"))

	return nil
}
  1. Remove deprecated method
		CreateWithStep().
		StepName("Step name").

you have to replace it by

		CreateStep("Step name").