Skip to content

Commit

Permalink
Change error message to indicate missing file (#7)
Browse files Browse the repository at this point in the history
Signed-off-by: Zabil Cheriya Maliackal <zabilcm@gmail.com>
  • Loading branch information
zabil committed Aug 24, 2020
1 parent 5b0a7c1 commit 24587c1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
8 changes: 4 additions & 4 deletions common.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,15 +70,15 @@ type Property struct {
func GetProjectRoot() (string, error) {
pwd, err := os.Getwd()
if err != nil {
return "", fmt.Errorf("Failed to find project root directory. %s\n", err.Error())
return "", fmt.Errorf("Failed to find Gauge project root directory. Missing manifest.json file: %s\n", err.Error())
}
return findManifestInPath(pwd)
}

func findManifestInPath(pwd string) (string, error) {
wd, err := filepath.Abs(pwd)
if err != nil {
return "", fmt.Errorf("Failed to find project directory: %s", err)
return "", fmt.Errorf("Failed to find Gauge project directory. Missing manifest.json file: %s", err)
}
manifestExists := func(dir string) bool {
return FileExists(filepath.Join(dir, ManifestFile))
Expand All @@ -90,12 +90,12 @@ func findManifestInPath(pwd string) (string, error) {
return dir, nil
}
if dir == filepath.Clean(fmt.Sprintf("%c", os.PathSeparator)) || dir == "" {
return "", fmt.Errorf("Failed to find project directory")
return "", fmt.Errorf("Failed to find Gauge project directory. Missing manifest.json file.")
}
oldDir := dir
dir = filepath.Clean(fmt.Sprintf("%s%c..", dir, os.PathSeparator))
if dir == oldDir {
return "", fmt.Errorf("Failed to find project directory")
return "", fmt.Errorf("Failed to find Gauge project directory. Missing manifest.json file.")
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions common_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ func (s *MySuite) TestGetProjectFailing(c *C) {

_, err := GetProjectRoot()
c.Assert(err, NotNil)
c.Assert(err.Error(), Equals, "Failed to find project directory")
c.Assert(err.Error(), Equals, "Failed to find Gauge project directory. Missing manifest.json file.")
}

func (s *MySuite) TestGetDirInProject(c *C) {
Expand Down Expand Up @@ -238,7 +238,7 @@ func (s *MySuite) TestGetProjectRootGivesErrorWhenProvidedInvalidSpecFilePath(c

root, err := GetProjectRootFromSpecPath("/specs/nested/deep_nested/deep_nested.spec")

c.Assert(err.Error(), Equals, fmt.Sprintf("Failed to find project directory"))
c.Assert(err.Error(), Equals, fmt.Sprintf("Failed to find Gauge project directory. Missing manifest.json file."))
c.Assert(root, Equals, "")
}

Expand Down

0 comments on commit 24587c1

Please sign in to comment.