зеркало из https://github.com/microsoft/abstrakt.git
Removed `file.Exists()` as it's not needed.
This commit is contained in:
Родитель
7e537d9796
Коммит
45f20493c7
13
cmd/diff.go
13
cmd/diff.go
|
@ -5,7 +5,6 @@ import (
|
|||
"fmt"
|
||||
"github.com/microsoft/abstrakt/internal/diff"
|
||||
"github.com/microsoft/abstrakt/internal/platform/constellation"
|
||||
"github.com/microsoft/abstrakt/tools/file"
|
||||
"github.com/microsoft/abstrakt/tools/logger"
|
||||
"github.com/spf13/cobra"
|
||||
"strings"
|
||||
|
@ -39,18 +38,10 @@ Example: abstrakt diff -o [constellationFilePathOriginal] -n [constellationFileP
|
|||
logger.Debugf("showOriginalOutput: %t", *cc.showOriginal)
|
||||
logger.Debugf("showNewOutput: %t", *cc.showNew)
|
||||
|
||||
if !file.Exists(cc.constellationFilePathOrg) {
|
||||
return fmt.Errorf("Could not open original YAML input file for reading %v", cc.constellationFilePathOrg)
|
||||
}
|
||||
|
||||
if !file.Exists(cc.constellationFilePathNew) {
|
||||
return fmt.Errorf("Could not open new YAML input file for reading %v", cc.constellationFilePathNew)
|
||||
}
|
||||
|
||||
dsGraphOrg := new(constellation.Config)
|
||||
err := dsGraphOrg.LoadFile(cc.constellationFilePathOrg)
|
||||
if err != nil {
|
||||
return fmt.Errorf("dagConfigService failed to load file %q: %s", cc.constellationFilePathOrg, err)
|
||||
return fmt.Errorf("Constellation config failed to load file %q: %s", cc.constellationFilePathOrg, err)
|
||||
}
|
||||
|
||||
if *cc.showOriginal {
|
||||
|
@ -66,7 +57,7 @@ Example: abstrakt diff -o [constellationFilePathOriginal] -n [constellationFileP
|
|||
dsGraphNew := new(constellation.Config)
|
||||
err = dsGraphNew.LoadFile(cc.constellationFilePathNew)
|
||||
if err != nil {
|
||||
return fmt.Errorf("dagConfigService failed to load file %q: %s", cc.constellationFilePathNew, err)
|
||||
return fmt.Errorf("Constellation config failed to load file %q: %s", cc.constellationFilePathNew, err)
|
||||
}
|
||||
|
||||
if *cc.showNew {
|
||||
|
|
|
@ -22,14 +22,14 @@ func TestDiffCmdWithAllRequirementsNoError(t *testing.T) {
|
|||
// TestDffCmdFailYaml - test diff command parameters
|
||||
// Test both required command line parameters (-o, -n) failing each in turn
|
||||
func TestDffCmdFailYaml(t *testing.T) {
|
||||
expected := "Could not open original YAML input file for reading constellationPathOrg"
|
||||
expected := "Constellation config failed to load file \"constellationPathOrg\": open constellationPathOrg: no such file or directory"
|
||||
|
||||
_, err := helper.ExecuteCommand(newDiffCmd().cmd, "-o", "constellationPathOrg", "-n", "constellationPathNew")
|
||||
|
||||
assert.Error(t, err)
|
||||
assert.EqualError(t, err, expected)
|
||||
|
||||
expected = "Could not open new YAML input file for reading constellationPathNew"
|
||||
expected = "Constellation config failed to load file \"constellationPathNew\": open constellationPathNew: no such file or directory"
|
||||
|
||||
_, err = helper.ExecuteCommand(newDiffCmd().cmd, "-o", "../examples/constellation/sample_constellation.yaml", "-n", "constellationPathNew")
|
||||
|
||||
|
@ -40,7 +40,7 @@ func TestDffCmdFailYaml(t *testing.T) {
|
|||
// TestDiffCmdFailNotYaml - test diff command parameters
|
||||
// Test both required command line parameter files fail when provided with invalid input files (-o, -n) failing each in turn
|
||||
func TestDiffCmdFailNotYaml(t *testing.T) {
|
||||
expected := "dagConfigService failed to load file \"diff.go\": yaml: line 26: mapping values are not allowed in this context"
|
||||
expected := "Constellation config failed to load file \"diff.go\": yaml: line 25: mapping values are not allowed in this context"
|
||||
|
||||
_, err := helper.ExecuteCommand(newDiffCmd().cmd, "-o", "diff.go", "-n", "diff.go")
|
||||
|
||||
|
|
|
@ -9,7 +9,6 @@ import (
|
|||
"bytes"
|
||||
"fmt"
|
||||
"github.com/microsoft/abstrakt/internal/platform/constellation"
|
||||
"github.com/microsoft/abstrakt/tools/file"
|
||||
"github.com/microsoft/abstrakt/tools/logger"
|
||||
"github.com/spf13/cobra"
|
||||
"strings"
|
||||
|
@ -34,14 +33,10 @@ Example: abstrakt visualise -f [constellationFilePath]`,
|
|||
logger.Debug("args: " + strings.Join(args, " "))
|
||||
logger.Debug("constellationFilePath: " + cc.constellationFilePath)
|
||||
|
||||
if !file.Exists(cc.constellationFilePath) {
|
||||
return fmt.Errorf("Could not open YAML input file for reading %v", cc.constellationFilePath)
|
||||
}
|
||||
|
||||
dsGraph := new(constellation.Config)
|
||||
err := dsGraph.LoadFile(cc.constellationFilePath)
|
||||
if err != nil {
|
||||
return fmt.Errorf("dagConfigService failed to load file %q: %s", cc.constellationFilePath, err)
|
||||
return fmt.Errorf("Constellation config failed to load file %q: %s", cc.constellationFilePath, err)
|
||||
}
|
||||
|
||||
out := &bytes.Buffer{}
|
||||
|
|
|
@ -23,7 +23,7 @@ func TestVisualiseCmdWithAllRequirementsNoError(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestVisualiseCmdFailYaml(t *testing.T) {
|
||||
expected := "Could not open YAML input file for reading"
|
||||
expected := "Constellation config failed to load file"
|
||||
|
||||
_, err := helper.ExecuteCommand(newVisualiseCmd().cmd, "-f", "constellationPath")
|
||||
|
||||
|
@ -32,7 +32,7 @@ func TestVisualiseCmdFailYaml(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestVisualiseCmdFailNotYaml(t *testing.T) {
|
||||
expected := "dagConfigService failed to load file"
|
||||
expected := "Constellation config failed to load file"
|
||||
|
||||
_, err := helper.ExecuteCommand(newVisualiseCmd().cmd, "-f", "visualise.go")
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче