Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MM-23110 CSV Exporter #3

Merged
merged 15 commits into from
Apr 16, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Rename CSVExporter to CSV
  • Loading branch information
agarciamontoro committed Mar 31, 2020

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
commit abb6eb05f5facbb978e4d7d5ee379a4475d6c78c
2 changes: 1 addition & 1 deletion server/command_hooks.go
Original file line number Diff line number Diff line change
@@ -64,7 +64,7 @@ func (p *Plugin) executeCommandExport(args *model.CommandArgs) *model.CommandRes
}
}

exporter := CSVExporter{}
exporter := CSV{}
fileName := exporter.FileName(channelToExport.Name)

exportedFileReader, exportedFileWriter := io.Pipe()
8 changes: 4 additions & 4 deletions server/csvExporter.go → server/csv.go
Original file line number Diff line number Diff line change
@@ -8,18 +8,18 @@ import (
"github.com/pkg/errors"
)

// CSVExporter exports all the posts in a channel to a chronollogically
// CSV exports all the posts in a channel to a chronollogically
// ordered file in CSV format
type CSVExporter struct{}
type CSV struct{}

// FileName returns the passed name with the .csv extension added
func (e *CSVExporter) FileName(name string) string {
func (e *CSV) FileName(name string) string {
return fmt.Sprintf("%s.csv", name)
}

// Export consumes all the posts returned by the iterator and writes them in
// CSV format to the writer
func (e *CSVExporter) Export(nextPosts PostIterator, writer io.Writer) error {
func (e *CSV) Export(nextPosts PostIterator, writer io.Writer) error {
csvWriter := csv.NewWriter(writer)
err := csvWriter.Write([]string{
"Post Creation Time",
4 changes: 2 additions & 2 deletions server/csvExporter_test.go → server/csv_test.go
Original file line number Diff line number Diff line change
@@ -10,7 +10,7 @@ import (
)

func TestFileName(t *testing.T) {
exporter := CSVExporter{}
exporter := CSV{}

testCases := []struct {
testName string
@@ -98,7 +98,7 @@ func TestExport(t *testing.T) {
}
}

exporter := CSVExporter{}
exporter := CSV{}

t.Run("Empty iterator", func(t *testing.T) {
var actualString strings.Builder