func preProcessTest(test *Test, defaultHost string) error {
	scheme := stringValue(test.Request.Scheme, "https")
	if scheme != "http" && scheme != "https" {
		return fmt.Errorf("invalid scheme %s. only http and https are supported", scheme)
	}
	test.Request.Scheme = scheme
	host := stringValue(test.Request.Host, defaultHost)
	if len(host) == 0 {
		return fmt.Errorf("no host specified for this test and no default host set")
	}
	test.Request.Host = host
	method := stringValue(test.Request.Method, "GET")
	if method != "GET" && method != "POST" && method != "PUT" && method != "PATCH" && method != "DELETE" && method != "HEAD" && method != "OPTIONS" && method != "PURGE" && method != "PROPFIND" {
		return fmt.Errorf("invalid method %s. only GET, POST, PUT, PATCH, DELETE, HEAD, OPTIONS, PURGE, PROPFIND are supported", method)
	}
	test.Request.Method = method
	if len(test.Request.Path) < 1 {
		return fmt.Errorf("request path is required")
	}
	if !strings.HasPrefix(test.Request.Path, "/") {
		return fmt.Errorf("request.path must start with /")
	}
	if err := ProcessDynamicHeaders(test.Request.DynamicHeaders, test.Request.Headers); err != nil {
		return err
	}
	headers := map[string]string{}
	for k, v := range test.Request.Headers {
		headers[strings.ToLower(k)] = v
	}
	test.Request.Headers = headers
	return nil
}
preProcessTest validates test and assigns default values
package main
import (
	"fmt"
	"io"
	"net/http"
	"os"
	"regexp"
	"strings"
)
type TestResult struct {
	Skipped bool
	Errors  []error
}
func RunTest(test *Test, defaultHost string) *TestResult {
	result := &TestResult{}
	if err := preProcessTest(test, defaultHost); err != nil {
		result.Errors = append(result.Errors, err)
		return result
	}
	conditionsMet, err := validateConditions(test)
	if err != nil {
		result.Errors = append(result.Errors, err)
		return result
	}
	if !conditionsMet {
		result.Skipped = true
		return result
	}
	url := test.Request.Scheme + "://" + test.Request.Host + test.Request.Path
	var body io.Reader
	if len(test.Request.Body) > 0 {
		body = strings.NewReader(test.Request.Body)
	}
	reqConfig := &HTTPRequestConfig{
		Method:               test.Request.Method,
		URL:                  url,
		Headers:              test.Request.Headers,
		Body:                 body,
		Attempts:             1,
		TimeoutSeconds:       60,
		SkipCertVerification: test.SkipCertVerification,
	}
	resp, respBody, err := SendHTTPRequest(reqConfig)
	if err != nil {
		result.Errors = append(result.Errors, err)
		return result
	}
	result.Errors = append(result.Errors, validateResponse(test, resp, respBody)...)
	return result
}