Skip to content

Commit

Permalink
feat(utils): impl current dir
Browse files Browse the repository at this point in the history
  • Loading branch information
jigsaw373 committed Apr 28, 2023
1 parent 1970f20 commit bfccc88
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
4 changes: 4 additions & 0 deletions pkg/utils/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,7 @@ func StoreFile(name string, contents string) error {

return nil
}

func CurrenDir() (string, error) {
return os.Getwd()
}
16 changes: 16 additions & 0 deletions pkg/utils/file_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,19 @@ func TestStoreFile(t *testing.T) {
t.Errorf("unexpected file contents: got %s, want %s", actual, contents)
}
}

func TestCurrenDir(t *testing.T) {
expectedDir, err := os.Getwd()
if err != nil {
t.Fatalf("Error getting current directory: %s", err)
}

actualDir, err := utils.CurrenDir()
if err != nil {
t.Fatalf("Unexpected error: %s", err)
}

if actualDir != expectedDir {
t.Errorf("Expected directory '%s', but got '%s'", expectedDir, actualDir)
}
}

0 comments on commit bfccc88

Please sign in to comment.