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) }
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) } } }
// 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 }