diff --git a/conduit/plugins/exporters/filewriter/util_test.go b/conduit/plugins/exporters/filewriter/util_test.go index 0e89716..d6f2482 100644 --- a/conduit/plugins/exporters/filewriter/util_test.go +++ b/conduit/plugins/exporters/filewriter/util_test.go @@ -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 { @@ -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) @@ -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 { @@ -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 {