From 67c5c4123bae6ce2cf31b096110e09c1dd47fd21 Mon Sep 17 00:00:00 2001 From: lucapette Date: Sun, 20 Jan 2019 10:52:11 +0100 Subject: [PATCH] Take into account newlines Fixes #67 --- Gopkg.lock | 11 ++++++++++- integration/cli_test.go | 2 +- integration/fixtures/file.txt | 2 +- integration/golden/unknown-format.golden | 2 +- pkg/fakedata/generator.go | 2 +- 5 files changed, 14 insertions(+), 5 deletions(-) diff --git a/Gopkg.lock b/Gopkg.lock index c525b19..5893706 100644 --- a/Gopkg.lock +++ b/Gopkg.lock @@ -3,25 +3,34 @@ [[projects]] branch = "master" + digest = "1:591a2778aa6e896980757ea87e659b3aa13d8c0e790310614028463a31c0998b" name = "github.com/kr/pretty" packages = ["."] + pruneopts = "" revision = "cfb55aafdaf3ec08f0db22699ab822c50091b1c4" [[projects]] branch = "master" + digest = "1:109e0a9b9e74c5c8adf94a2dc4dd4a9ca2a183d4d87ffecd4e62db69a5ede55a" name = "github.com/kr/text" packages = ["."] + pruneopts = "" revision = "7cafcd837844e784b526369c9bce262804aebc60" [[projects]] + digest = "1:261bc565833ef4f02121450d74eb88d5ae4bd74bfe5d0e862cddb8550ec35000" name = "github.com/spf13/pflag" packages = ["."] + pruneopts = "" revision = "e57e3eeb33f795204c1ca35f56c44f83227c6e66" version = "v1.0.0" [solve-meta] analyzer-name = "dep" analyzer-version = 1 - inputs-digest = "337714b7d370d6e951421b82647b8770ddee2dc85becf58f08f69240262cd2ff" + input-imports = [ + "github.com/kr/pretty", + "github.com/spf13/pflag", + ] solver-name = "gps-cdcl" solver-version = 1 diff --git a/integration/cli_test.go b/integration/cli_test.go index c173c65..65abff5 100644 --- a/integration/cli_test.go +++ b/integration/cli_test.go @@ -157,7 +157,7 @@ func TestCLI(t *testing.T) { }, { "unknown format", - []string{"-f=sqll", "-t=USERS", "int:42,42", "enum:foo,foo"}, + []string{"-f=no-format", "-t=USERS", "int:42,42", "enum:foo,foo"}, "unknown-format.golden", true, }, diff --git a/integration/fixtures/file.txt b/integration/fixtures/file.txt index 1293e19..705d9f4 100644 --- a/integration/fixtures/file.txt +++ b/integration/fixtures/file.txt @@ -7,4 +7,4 @@ from-an-existing-file from-an-existing-file from-an-existing-file from-an-existing-file -from-an-existing-file \ No newline at end of file +from-an-existing-file diff --git a/integration/golden/unknown-format.golden b/integration/golden/unknown-format.golden index 03fa4dd..3398a70 100644 --- a/integration/golden/unknown-format.golden +++ b/integration/golden/unknown-format.golden @@ -1,4 +1,4 @@ -unknown format: sqll +unknown format: no-format Usage: fakedata [option ...] field... diff --git a/pkg/fakedata/generator.go b/pkg/fakedata/generator.go index b61355e..4b2d869 100644 --- a/pkg/fakedata/generator.go +++ b/pkg/fakedata/generator.go @@ -186,7 +186,7 @@ func file(path string) (func() string, error) { if err != nil { return nil, fmt.Errorf("could not read file %s: %v", filePath, err) } - list := strings.Split(string(content), "\n") + list := strings.Split(strings.Trim(string(content), "\n"), "\n") return func() string { return withList(list)() }, nil }