Skip to content

Commit

Permalink
test package fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
jfbus committed Jul 24, 2020
1 parent 8169cc4 commit c0da5a9
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 12 deletions.
11 changes: 5 additions & 6 deletions format_test.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
package dynjson_test
package dynjson

import (
"encoding/json"
"fmt"
"io/ioutil"
"pkgs/dynjson"
"strings"
"testing"
)
Expand Down Expand Up @@ -338,7 +337,7 @@ func TestFormat(t *testing.T) {
}
for i, tt := range tests {
t.Run(fmt.Sprintf("test #%d", i), func(t *testing.T) {
f := dynjson.NewFormatter()
f := NewFormatter()
var fields []string
if tt.format != "" {
fields = strings.Split(tt.format, ",")
Expand Down Expand Up @@ -378,7 +377,7 @@ func TestFormatAnonymous(t *testing.T) {
Embedded: Embedded{Foo: 1},
Bar: 2,
}
f := dynjson.NewFormatter()
f := NewFormatter()
o, err := f.Format(src, []string{"foo.foo", "bar"})
if err != nil {
t.Error("Should not have returned", err)
Expand All @@ -393,7 +392,7 @@ func TestFormatAnonymous(t *testing.T) {
}

func BenchmarkFormat_Fields(b *testing.B) {
f := dynjson.NewFormatter()
f := NewFormatter()
w := json.NewEncoder(ioutil.Discard)
for i := 0; i < b.N; i++ {
o, _ := f.Format(struct {
Expand All @@ -405,7 +404,7 @@ func BenchmarkFormat_Fields(b *testing.B) {
}

func BenchmarkFormat_NoFields(b *testing.B) {
f := dynjson.NewFormatter()
f := NewFormatter()
w := json.NewEncoder(ioutil.Discard)
for i := 0; i < b.N; i++ {
o, _ := f.Format(struct {
Expand Down
10 changes: 4 additions & 6 deletions request_test.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
package dynjson_test
package dynjson

import (
"net/http"
"testing"

"pkgs/dynjson"
)

func TestFieldsFromRequest(t *testing.T) {
Expand All @@ -13,7 +11,7 @@ func TestFieldsFromRequest(t *testing.T) {
if err != nil {
t.Error("Should not have returned", err)
}
fields := dynjson.FieldsFromRequest(r)
fields := FieldsFromRequest(r)
if len(fields) != 2 {
t.Error("2 fields were expected")
}
Expand All @@ -26,7 +24,7 @@ func TestFieldsFromRequest(t *testing.T) {
if err != nil {
t.Error("Should not have returned", err)
}
fields := dynjson.FieldsFromRequest(r, dynjson.OptionMultipleFields)
fields := FieldsFromRequest(r, OptionMultipleFields)
if len(fields) != 2 {
t.Error("2 fields were expected")
}
Expand All @@ -39,7 +37,7 @@ func TestFieldsFromRequest(t *testing.T) {
if err != nil {
t.Error("Should not have returned", err)
}
fields := dynjson.FieldsFromRequest(r, dynjson.OptionCommaList)
fields := FieldsFromRequest(r, OptionCommaList)
if len(fields) != 2 {
t.Error("2 fields were expected")
}
Expand Down

0 comments on commit c0da5a9

Please sign in to comment.