Example #1
0
func main() {
	runtime.GOMAXPROCS(runtime.NumCPU())
	rand.Seed(int64(time.Second))

	flag.Usage = usage
	flag.Parse()

	if *urlFlag == "" || (*authUrlFlag != "" && *authValFlag == "") {
		usage()
		os.Exit(0)
	}

	Logger.Infof("Start to create testcase: %s REST url: %s.", *outputFlag, *urlFlag)
	defer Logger.Infof("Create testcase: %s done.", *outputFlag)

	var auth *testcase_util.Auth
	client := http.NewAuthClient()
	if *authUrlFlag != "" {
		authValues := parseAuthVals(*authValFlag)
		auth = testcase_util.NewAuth(*authUrlFlag, authValues)

		err := client.Auth(auth.Url, auth.Vals)
		checkErr(err)
	}
	result, err := client.Get(*urlFlag)
	checkErr(err)

	testcase, err := testcase_util.NewTestcase(*outputFlag, *urlFlag, testcase_util.GET, result, auth)
	checkErr(err)

	err = testcase.ToJsonFile()
	checkErr(err)
}
Example #2
0
func NewRunner(testcases []*Testcase, times int) *Runner {
	if times <= 0 {
		times = 1
	}

	return &Runner{
		testcases:  testcases,
		times:      times,
		httpClient: http.NewAuthClient(),
		report:     NewReport(testcases, times),
	}
}