Skip to content

Instantly share code, notes, and snippets.

@michaeljs1990
Created August 9, 2014 17:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save michaeljs1990/98e900db67f96428b4d3 to your computer and use it in GitHub Desktop.
Save michaeljs1990/98e900db67f96428b4d3 to your computer and use it in GitHub Desktop.
contentbody declared and not used.
// Run all tests and log to file
func RunTests(tests []testCase) {
color.Blue("Starting test casses...")
client := &http.Client{}
for _, test := range tests {
color.Blue("Test: " + test.Name)
color.Blue(test.Method + " " + test.Path)
if data, err := test.Sent.MarshalJSON(); err == nil {
var contentbody io.Reader = nil
if string(data) != "null" {
contentbody := bytes.NewReader(data)
}
if req, err := http.NewRequest(test.Method, test.Path, contentbody); err == nil {
if resp, err := client.Do(req); err == nil {
if returned, err := ioutil.ReadAll(resp.Body); err == nil {
fmt.Println(string(returned))
} else {
color.Red(err.Error())
}
} else {
color.Red(err.Error())
}
} else {
color.Red(err.Error())
}
} else {
color.Red(err.Error())
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment