Skip to content

Commit

Permalink
gofmt
Browse files Browse the repository at this point in the history
  • Loading branch information
Zeph Grunschlag committed Aug 18, 2023
1 parent b46628f commit b7c82a1
Showing 1 changed file with 63 additions and 64 deletions.
127 changes: 63 additions & 64 deletions conduit/plugins/exporters/filewriter/util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,84 +8,83 @@ import (
"github.com/stretchr/testify/require"
)


func TestParseFilenameFormat(t *testing.T) {
testCases := []struct {
name string
format string
gzip bool
name string
format string
gzip bool
blockFormat EncodingFormat
err string
err string
}{
{
name: "messagepack vanilla",
format: "%d_block.msgp",
gzip: false,
name: "messagepack vanilla",
format: "%d_block.msgp",
gzip: false,
blockFormat: MessagepackFormat,
err: "",
err: "",
},
{
name: "messagepack gzip",
format: "%d_block.msgp.gz",
gzip: true,
name: "messagepack gzip",
format: "%d_block.msgp.gz",
gzip: true,
blockFormat: MessagepackFormat,
err: "",
err: "",
},
{
name: "json vanilla",
format: "%d_block.json",
gzip: false,
name: "json vanilla",
format: "%d_block.json",
gzip: false,
blockFormat: JSONFormat,
err: "",
err: "",
},
{
name: "json gzip",
format: "%d_block.json.gz",
gzip: true,
name: "json gzip",
format: "%d_block.json.gz",
gzip: true,
blockFormat: JSONFormat,
err: "",
err: "",
},
{
name: "messagepack vanilla 2",
format: "%[1]d_block round%[1]d.msgp",
gzip: false,
name: "messagepack vanilla 2",
format: "%[1]d_block round%[1]d.msgp",
gzip: false,
blockFormat: MessagepackFormat,
err: "",
err: "",
},
{
name: "messagepack gzip 2",
format: "%[1]d_block round%[1]d.msgp.gz",
gzip: true,
name: "messagepack gzip 2",
format: "%[1]d_block round%[1]d.msgp.gz",
gzip: true,
blockFormat: MessagepackFormat,
err: "",
err: "",
},
{
name: "json vanilla 2",
format: "%[1]d_block round%[1]d.json",
gzip: false,
name: "json vanilla 2",
format: "%[1]d_block round%[1]d.json",
gzip: false,
blockFormat: JSONFormat,
err: "",
err: "",
},
{
name: "json gzip 2",
format: "%[1]d_block round%[1]d.json.gz",
gzip: true,
name: "json gzip 2",
format: "%[1]d_block round%[1]d.json.gz",
gzip: true,
blockFormat: JSONFormat,
err: "",
err: "",
},
{
name: "invalid - gzip",
format: "%d_block.msgp.gzip",
gzip: false,
name: "invalid - gzip",
format: "%d_block.msgp.gzip",
gzip: false,
blockFormat: UnrecognizedFormat,
err: "unrecognized export format",
err: "unrecognized export format",
},
{
name: "invalid - no extension",
format: "%d_block",
gzip: false,
name: "invalid - no extension",
format: "%d_block",
gzip: false,
blockFormat: UnrecognizedFormat,
err: "unrecognized export format",
err: "unrecognized export format",
},
}
for _, tc := range testCases {
Expand All @@ -94,7 +93,7 @@ func TestParseFilenameFormat(t *testing.T) {
t.Parallel()

blockFormat, gzip, err := ParseFilenamePattern(tc.format)
if tc.err == "" {
if tc.err == "" {
require.NoError(t, err)
require.Equal(t, tc.gzip, gzip)
require.Equal(t, tc.blockFormat, blockFormat)
Expand All @@ -108,38 +107,38 @@ func TestParseFilenameFormat(t *testing.T) {
func TestGenesisFilename(t *testing.T) {
testCases := []struct {
blockFormat EncodingFormat
gzip bool
result string
err string
gzip bool
result string
err string
}{
{
blockFormat: MessagepackFormat,
gzip: false,
result: "genesis.msgp",
err: "",
gzip: false,
result: "genesis.msgp",
err: "",
},
{
blockFormat: MessagepackFormat,
gzip: true,
result: "genesis.msgp.gz",
err: "",
gzip: true,
result: "genesis.msgp.gz",
err: "",
},
{
blockFormat: JSONFormat,
gzip: false,
result: "genesis.json",
err: "",
gzip: false,
result: "genesis.json",
err: "",
},
{
blockFormat: JSONFormat,
gzip: true,
result: "genesis.json.gz",
err: "",
gzip: true,
result: "genesis.json.gz",
err: "",
},
{
result: "error case",
result: "error case",
blockFormat: EncodingFormat(42),
err: "GenesisFilename(): unhandled format 42",
err: "GenesisFilename(): unhandled format 42",
},
}
for _, tc := range testCases {
Expand All @@ -148,7 +147,7 @@ func TestGenesisFilename(t *testing.T) {
t.Parallel()

filename, err := GenesisFilename(tc.blockFormat, tc.gzip)
if tc.err == "" {
if tc.err == "" {
require.NoError(t, err)
require.Equal(t, tc.result, filename)
} else {
Expand Down

0 comments on commit b7c82a1

Please sign in to comment.