Skip to content

Commit

Permalink
fix: broken toml parser tests
Browse files Browse the repository at this point in the history
  • Loading branch information
rhnvrm committed Mar 6, 2024
1 parent 1ecb1b3 commit e2e0cc2
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions parsers/toml/toml_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package toml

import (
"sort"
"strings"
"testing"

"github.com/stretchr/testify/assert"
Expand Down Expand Up @@ -110,7 +112,7 @@ number = 2.0
"object": map[string]interface{}{"a": "b", "c": "d"},
"string": "Hello World",
},
output: []byte(`array = [1,2,3,4,5]
output: []byte(`array = [1, 2, 3, 4, 5]
boolean = true
color = "gold"
number = 123
Expand All @@ -132,8 +134,16 @@ string = "Hello World"
assert.NotNil(t, err)
} else {
assert.Nil(t, err)
assert.Equal(t, tc.output, out)
assert.Equal(t, sortLines(tc.output), sortLines(out))
}
})
}
}

// toml marshal is not guaranteed to produce the same output every time
// so we sort the lines before comparing.
func sortLines(s []byte) string {
lines := strings.Split(string(s), "\n")
sort.Strings(lines)
return strings.Join(lines, "\n")
}

0 comments on commit e2e0cc2

Please sign in to comment.