Skip to content

Commit

Permalink
Merge pull request #2 from antham/fix-missing-extra-new-line
Browse files Browse the repository at this point in the history
Add missing extra new line when formatting
  • Loading branch information
antham committed Sep 4, 2018
2 parents 605d89d + bc5112e commit 8db0971
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 23 deletions.
13 changes: 6 additions & 7 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,14 @@ jobs:
steps:
- checkout
- run:
name: Get doc-hunt binary
name: Install dependencies
command: |
mkdir /home/circleci/bin
wget -O ~/bin/doc-hunt https://github.com/antham/doc-hunt/releases/download/v2.1.1/doc-hunt_linux_amd64 && chmod 777 ~/bin/doc-hunt
- run:
name: Get gommit binary
command: |
wget -O ~/bin/gommit https://github.com/antham/gommit/releases/download/v2.1.1/gommit_linux_386 && chmod 777 ~/bin/gommit
- run:
name: Install dep and gometalinter
command: |
go get -u github.com/golang/dep/cmd/dep
go get github.com/alecthomas/gometalinter
go get -u github.com/mitchellh/gox
gometalinter --install --update
- run:
name: Install vendors
Expand All @@ -35,6 +30,10 @@ jobs:
name: Run tests
command: |
make run-tests
- run:
name: Compile
command: |
gox -output "build/{{.Dir}}_{{.OS}}_{{.Arch}}"
- run:
name: Run gommit
command: |
Expand Down
6 changes: 4 additions & 2 deletions cmd/fmt_replace_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ func TestFormatAndReplace(t *testing.T) {
b1Expected := `Feature: Test
Test
Scenario: Scenario1
Given a test`
Given a test
`

assert.EqualValues(t, b1Expected, string(b1))

Expand All @@ -75,7 +76,8 @@ func TestFormatAndReplace(t *testing.T) {
b2Expected := `Feature: Test
Test
Scenario: Scenario2
Given a test`
Given a test
`

assert.EqualValues(t, b2Expected, string(b2))
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/fmt_stdout.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ func formatOnStdout(msgHandler messageHandler, cmd *cobra.Command, args []string
msgHandler.errorFatal(err)
}

msgHandler.print("%s\n", output.String())
msgHandler.print("%s", output.String())
}

func init() {
Expand Down
23 changes: 15 additions & 8 deletions ghokin/file_manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func TestFileManagerTransform(t *testing.T) {
b, e := ioutil.ReadFile("fixtures/file1.feature")

assert.NoError(t, e)
assert.EqualValues(t, string(b[:len(b)-1]), buf.String())
assert.EqualValues(t, string(b), buf.String())
},
},
{
Expand Down Expand Up @@ -84,7 +84,8 @@ hello world
Then whatever
"""
hello world
"""`
"""
`

b, e := ioutil.ReadFile("/tmp/ghokin/file1.feature")

Expand All @@ -104,7 +105,8 @@ Scenario: scenario%d
Then whatever
"""
hello world
"""`)
"""
`)

assert.NoError(t, os.RemoveAll("/tmp/ghokin"))
assert.NoError(t, os.MkdirAll("/tmp/ghokin", 0777))
Expand Down Expand Up @@ -133,7 +135,8 @@ hello world
Then whatever
"""
hello world
"""`
"""
`

for i, f := range []string{
"/tmp/ghokin/file1.feature",
Expand Down Expand Up @@ -162,7 +165,8 @@ Scenario: scenario
Then whatever
"""
hello world
"""`)
"""
`)

assert.NoError(t, os.RemoveAll("/tmp/ghokin"))
assert.NoError(t, os.MkdirAll("/tmp/ghokin", 0777))
Expand Down Expand Up @@ -210,7 +214,8 @@ Scenario: scenario
Then whatever
"""
hello world
"""`)
"""
`)

assert.NoError(t, os.RemoveAll("/tmp/ghokin"))
assert.NoError(t, os.MkdirAll("/tmp/ghokin", 0777))
Expand All @@ -230,7 +235,8 @@ hello world
Then whatever
"""
hello world
"""`
"""
`

contentUnformatted := `Feature: test
test
Expand All @@ -240,7 +246,8 @@ Scenario: scenario
Then whatever
"""
hello world
"""`
"""
`

for _, s := range []struct {
filename string
Expand Down
2 changes: 1 addition & 1 deletion ghokin/transformer.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ func transform(section *section, indentConf indent, aliases aliases) (bytes.Buff
func buildBuffer(document []string) (bytes.Buffer, error) {
var buf bytes.Buffer

if _, err := buf.WriteString(strings.Join(document, "\n")); err != nil {
if _, err := buf.WriteString(strings.Join(document, "\n") + "\n"); err != nil {
return bytes.Buffer{}, err
}

Expand Down
8 changes: 4 additions & 4 deletions ghokin/transformer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,7 @@ func TestTransform(t *testing.T) {
b, e := ioutil.ReadFile("fixtures/file1.feature")

assert.NoError(t, e)
assert.EqualValues(t, string(b[:len(b)-1]), buf.String())
assert.EqualValues(t, string(b), buf.String())
},
},
{
Expand All @@ -430,7 +430,7 @@ func TestTransform(t *testing.T) {
b, e := ioutil.ReadFile("fixtures/cmd.expected.feature")

assert.NoError(t, e)
assert.EqualValues(t, string(b[:len(b)-1]), buf.String())
assert.EqualValues(t, string(b), buf.String())
},
},
{
Expand All @@ -441,7 +441,7 @@ func TestTransform(t *testing.T) {
b, e := ioutil.ReadFile("fixtures/multisize-table.expected.feature")

assert.NoError(t, e)
assert.EqualValues(t, string(b[:len(b)-1]), buf.String())
assert.EqualValues(t, string(b), buf.String())
},
},
{
Expand All @@ -452,7 +452,7 @@ func TestTransform(t *testing.T) {
b, e := ioutil.ReadFile("fixtures/docstring-empty.expected.feature")

assert.NoError(t, e)
assert.EqualValues(t, string(b[:len(b)-1]), buf.String())
assert.EqualValues(t, string(b), buf.String())
},
},
}
Expand Down

0 comments on commit 8db0971

Please sign in to comment.