Beispiel #1
0
func TestGetComponents(t *testing.T) {
	const componentRoute = "/components"
	resp, apiServer, err := testGet(componentRoute)
	if apiServer != nil {
		apiServer.Close()
	}
	assert.NoErr(t, err)
	assert200(t, resp)
	respData, err := ioutil.ReadAll(resp.Body)
	assert.NoErr(t, err)
	cluster, err := data.ParseJSONCluster(respData)
	assert.NoErr(t, err)
	mockData, err := mocks.GetMockCluster()
	assert.NoErr(t, err)
	mockCluster, err := data.ParseJSONCluster(mockData)
	assert.NoErr(t, err)
	assert.Equal(t, cluster.ID, mockCluster.ID, "cluster ID value")
	for i, component := range cluster.Components {
		assert.Equal(t, component.Component, mockCluster.Components[i].Component, "component type")
		assert.Equal(t, component.Version, mockCluster.Components[i].Version, "version type")
		_, err := mocks.GetMockLatest(component.Component.Name)
		assert.NoErr(t, err)
		// TODO add tests for UpdateAvailable field
	}
}
Beispiel #2
0
func getMockLatest(name string, t *testing.T) models.Version {
	version, err := mocks.GetMockLatest(name)
	assert.NoErr(t, err)
	return version
}