Пример #1
0
// NewWorkspace initializes an empty OpenControl struct
func NewWorkspace() common.Workspace {
	return &localWorkspace{
		justifications: result.NewJustifications(),
		components:     newComponents(),
		standards:      newStandards(),
	}
}
func TestLoadSameComponentTwice(t *testing.T) {
	ws := localWorkspace{components: newComponents(), justifications: result.NewJustifications()}
	componentPath := filepath.Join("..", "fixtures", "component_fixtures", "v3_1_0", "EC2")
	err := ws.LoadComponent(componentPath)
	// Should load the component without a problem.
	assert.Nil(t, err)
	actualComponent, found := ws.components.get("EC2")
	assert.True(t, found)
	assert.NotNil(t, actualComponent)
	// Try to load component again.
	err = ws.LoadComponent(componentPath)
	// Should return an error that this component was already loaded.
	assert.NotNil(t, err)
	assert.Equal(t, "Component: EC2 exists!\n", err.Error())
}