func()

in client/validate.go [168:203]


func (v validator) validateTyped(url string) error {
	type request struct {
		Message string `json:"message"`
	}

	req := request{
		Message: "Hello world!",
	}

	reqJson, err := json.Marshal(req)

	if err != nil {
		return fmt.Errorf("failed to marshal json: %v", err)
	}

	body, err := sendHTTP(url, reqJson)

	if err != nil {
		return fmt.Errorf("failed to get response from HTTP function: %v", err)
	}

	type response struct {
		Payload request `json:"payload"`
	}

	var resJson response
	if err := json.Unmarshal(body, &resJson); err != nil {
		return fmt.Errorf("failed to unmarshal function output JSON: %v, function output: %q", err, string(body))
	}

	if !reflect.DeepEqual(resJson.Payload, req) {
		return fmt.Errorf("Got response.Payload = %v, wanted %v", resJson.Payload, req)
	}

	return nil
}