Exemplo n.º 1
0
func loadValidAndTestComponent(path string, t *testing.T, example common.Component) {
	actualComponent, err := components.Load(path)
	if !assert.Nil(t, err) {
		t.Fatalf("Expected reading component found in %s to be successful", path)
	}

	testSet(example, actualComponent, t)

}
Exemplo n.º 2
0
func TestLoadComponentErrors(t *testing.T) {
	for _, example := range componentTestErrors {
		_, actualError := components.Load(example.componentDir)
		// Check that the expected error is the actual error
		if !assert.Equal(t, example.expectedError, actualError) {
			t.Errorf("Expected %s, Actual: %s", example.expectedError, actualError)
		}
	}
}
Exemplo n.º 3
0
// LoadComponent imports components into a Component struct and adds it to the
// Components map.
func (ws *localWorkspace) LoadComponent(componentDir string) error {
	component, err := components.Load(componentDir)
	if err != nil {
		return err
	}
	// If the component is new, make sure we load the justifications as well.
	if ws.components.compareAndAdd(component) {
		ws.justifications.LoadMappings(component)
	} else {
		return fmt.Errorf("Component: %s exists!\n", component.GetKey())
	}
	return nil
}