Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added fake Directories and Absolute File Paths #111

Merged
merged 5 commits into from Aug 7, 2022

Conversation

adrubesh
Copy link
Contributor

@adrubesh adrubesh commented Aug 5, 2022

Description

This PR adds fake directories to file.go, including tests.

Are you trying to fix an existing issue?

No

Go Version

$ go version
# replace this line with the output

Go Tests

➜  faker git:(file_directories) ✗ go test -v -run "TestDriveLetter|TestAbsolutePath|TestDirectory"
=== RUN   TestDirectory
--- PASS: TestDirectory (0.00s)
=== RUN   TestDriveLetter
--- PASS: TestDriveLetter (0.00s)
=== RUN   TestAbsolutePath
--- PASS: TestAbsolutePath (0.00s)
PASS
ok      github.com/jaswdr/faker 0.004s


➜  faker git:(file_directories) ✗ GOOS=windows go test -v -run "TestDriveLetter|TestAbsolutePath|TestDirectory"
=== RUN   TestDirectory
--- PASS: TestDirectory (0.00s)
=== RUN   TestDriveLetter
--- PASS: TestDriveLetter (0.00s)
=== RUN   TestAbsolutePath
--- PASS: TestAbsolutePath (0.00s)
PASS
ok      github.com/jaswdr/faker 0.166s

Copy link
Owner

@jaswdr jaswdr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank very much for your contribution. I left some comments, please take a look when possible.

file.go Outdated Show resolved Hide resolved
file.go Outdated Show resolved Hide resolved
@adrubesh
Copy link
Contributor Author

adrubesh commented Aug 5, 2022

@jaswdr I made some of the changes you requested, and implemented some additional OS independent pathing. Here is some example output:

GOOS:  linux
====Fake Directories====
Directory(2):           /officiis/voluptatum
UnixDirectory(2):       /dolorum/et
WindowsDirectory(2):    x:\odio\accusamus
DriveLetter():          a:\
====Fake File Paths====
AbsoluteFilePath(2):            /nemo/expedita/impedit.csv
AbsoluteFilePathForUnix(2):     /molestias/aut/enim.m3u
AbsoluteFilePathForWindows(2):  e:\dolores\maiores\in.eot

GOOS:  windows
====Fake Directories====
Directory(2):           w:\libero\excepturi
UnixDirectory(2):       /id/rerum
WindowsDirectory(2):    n:\quos\aut
DriveLetter():          e:\
====Fake File Paths====
AbsoluteFilePath(2):            x:\in\est\rerum.pl
AbsoluteFilePathForUnix(2):     /eveniet/perspiciatis/ratione.ttf
AbsoluteFilePathForWindows(2):  s:\doloremque\voluptas\et.gif

directory.go Outdated Show resolved Hide resolved
file.go Show resolved Hide resolved
@adrubesh
Copy link
Contributor Author

adrubesh commented Aug 6, 2022

@jaswdr I added the OSResolver interface to take care of that, wasn't sure if it needed to go it utils.go, file.go or directory.go but utils.go seemed like a good place for it. Let me know what you think.

@adrubesh adrubesh changed the title Added fake Directories to file.go Added fake Directories and Absolute File Paths Aug 6, 2022
Copy link
Owner

@jaswdr jaswdr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, merging.

@jaswdr jaswdr merged commit 9d24d83 into jaswdr:master Aug 7, 2022
@jaswdr
Copy link
Owner

jaswdr commented Aug 7, 2022

Released in v1.15.0, congratulations for your first contribution 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants