Example #1
0
func TestXMLMockFail(t *testing.T) {
	t.Parallel()
	assert := assert.New(t)
	bad := unsupportedItem{
		Item: "hello",
	}
	_, err := mockserver.XML(201, bad)
	assert.Error(err)
}
Example #2
0
func TestNewMockXMLServer(t *testing.T) {
	t.Parallel()
	assert := assert.New(t)
	o := testItem{
		Item:  "testing",
		Count: 1234,
	}
	server, err := mockserver.XML(201, o)
	assert.NoError(err)
	defer server.Close()
	resp, err := http.Get(server.URL + "/testing")
	assert.NoError(err)
	assert.Equal(201, resp.StatusCode)
	b, err := parseResp(resp.Body)
	assert.NoError(err)
	samp, err := xml.Marshal(o)
	assert.NoError(err)
	assert.Equal(string(samp), b)
}