Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ https://godoc.org/github.com/icrowley/fake
To run the project tests:

```shell
cd test
go test
```

Expand Down
1,086 changes: 880 additions & 206 deletions data.go

Large diffs are not rendered by default.

14 changes: 14 additions & 0 deletions data/en/file_extensions
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
pdf
doc
docx
xls
xlsx
ppt
pptx
zip
png
jpg
mp3
mp4
dmg
exe
2 changes: 1 addition & 1 deletion fake.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ func (s *rndSrc) Seed(n int64) {
// GetLangs returns a slice of available languages
func GetLangs() []string {
var langs []string
for k, v := range data {
for k, v := range _escData {
if v.isDir && k != "/" && k != "/data" {
langs = append(langs, strings.Replace(k, "/data/", "", 1))
}
Expand Down
15 changes: 15 additions & 0 deletions files.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package fake

import (
"strings"
)

// FileExtension generates random file extension
func FileExtension() string {
return lookup(lang, "file_extensions", true)
}

// FileName generates random filename (including extension)
func FileName() string {
return strings.Replace(WordsN(r.Intn(2)+1), " ", "-", -1) + "." + FileExtension()
}
21 changes: 21 additions & 0 deletions files_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package fake

import (
"testing"
)

func TestFiles(t *testing.T) {
for _, lang := range GetLangs() {
SetLang(lang)

v := FileName()
if v == "" {
t.Errorf("FileName failed with lang %s", lang)
}

v = FileExtension()
if v == "" {
t.Errorf("FileExtension failed with lang %s", lang)
}
}
}