Skip to content

Instantly share code, notes, and snippets.

@akantsevoi
Created April 13, 2020 19:30
Show Gist options
  • Save akantsevoi/7f795c7b14f6d5dc0f66ace099e37296 to your computer and use it in GitHub Desktop.
Save akantsevoi/7f795c7b14f6d5dc0f66ace099e37296 to your computer and use it in GitHub Desktop.
func Test(t *testing.T) {
response := struct {
Success string `json:"success"`
}{}
requestHelper(
t,
"POST",
"/write",
strings.NewReader(`{"message":"text"}`),
&response,
)
require.Equal(t, "ok", response.Success)
var result []struct {
ID int64 `json:"id"`
Message string `json:"text"`
}
requestHelper(t, "GET", "/read", nil, &result)
require.Equal(t, 1, len(result))
require.Equal(t, "text", result[0].Message)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment