Example #1
0
func TestGetMetadata(t *testing.T) {
	setup()
	defer teardown()
	fakeManager := FakeManager{
		Metadata: agent.Metadata{Agent: agent.AgentMetadata{Version: "1"}},
	}

	handlerCalled := false
	handler := func(w http.ResponseWriter, r *http.Request) {
		handlerCalled = true
		api.Metadata(&fakeManager, w, r)
	}
	router.Methods("GET").Path(api.URLForMetadata()).Name("test").HandlerFunc(handler)

	m, err := client.GetMetadata()
	assert.NoError(t, err)
	assert.Equal(t, "1", m.Agent.Version)
	assert.True(t, handlerCalled)
}
Example #2
0
// GetMetadata fetches metadata for the agent and adapter.
func (c APIClient) GetMetadata() (agent.Metadata, error) {
	var metadata agent.Metadata
	err := c.doRequest("GET", api.URLForMetadata(), &metadata, nil)
	return metadata, err
}