-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(console): add support for multiple input files (#729)
* feat(console): add support for multiple input files * fix: test updates * fix: doc updates * fix: file save workflow
- Loading branch information
1 parent
86c9376
commit 103ca0d
Showing
7 changed files
with
308 additions
and
87 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package console_test | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/require" | ||
|
||
"github.com/defenseunicorns/lula/src/cmd/console" | ||
) | ||
|
||
func TestGetModelsByFiles(t *testing.T) { | ||
t.Run("Get output models by files", func(t *testing.T) { | ||
setOutputFiles := make(map[string]string) | ||
inputFiles := []string{"../../test/unit/common/oscal/valid-component.yaml", "../../test/unit/common/oscal/valid-generated-component.yaml", "../../test/unit/common/oscal/valid-assessment-results.yaml"} | ||
models, modelFiles, err := console.GetModelsByFiles(inputFiles, setOutputFiles) | ||
require.NoError(t, err) | ||
|
||
require.Len(t, models, 2) | ||
require.Len(t, modelFiles, 2) | ||
|
||
require.NotNil(t, models["component"].ComponentDefinition) | ||
require.NotNil(t, models["assessment-results"].AssessmentResults) | ||
|
||
require.Equal(t, modelFiles["component"], "component.yaml") | ||
require.Equal(t, modelFiles["assessment-results"], "../../test/unit/common/oscal/valid-assessment-results.yaml") | ||
}) | ||
|
||
t.Run("Override output model files", func(t *testing.T) { | ||
setOutputFiles := make(map[string]string) | ||
setOutputFiles["component"] = "component-override.yaml" | ||
|
||
inputFiles := []string{"../../test/unit/common/oscal/valid-component.yaml", "../../test/unit/common/oscal/valid-generated-component.yaml", "../../test/unit/common/oscal/valid-assessment-results.yaml"} | ||
_, modelFiles, err := console.GetModelsByFiles(inputFiles, setOutputFiles) | ||
require.NoError(t, err) | ||
|
||
require.Equal(t, modelFiles["component"], "component-override.yaml") | ||
require.Equal(t, modelFiles["assessment-results"], "../../test/unit/common/oscal/valid-assessment-results.yaml") | ||
}) | ||
} |
Oops, something went wrong.