Home | History | Annotate | Download | only in mappers
      1 package mappers
      2 
      3 import (
      4 	"testing"
      5 
      6 	"github.com/stretchr/testify/assert"
      7 	c "repodiff/constants"
      8 	e "repodiff/entities"
      9 )
     10 
     11 func TestCommitEntityToCSVRow(t *testing.T) {
     12 	commitRow := e.AnalyzedCommitRow{
     13 		CommitRow: e.CommitRow{
     14 			Date:              "2018/03/19",
     15 			Commit:            "4cc9725c953f57f8abe63b729e26125feac1be4e",
     16 			DownstreamProject: "platform/tools/external/gradle",
     17 			Author:            "jeffrey.lebowski (a] google.com",
     18 			Subject:           "Take any rug in the house",
     19 		},
     20 		Type: c.Global,
     21 	}
     22 	csvRow := CommitEntityToCSVRow(commitRow)
     23 	expected := []string{
     24 		"\"2018/03/19\"",
     25 		"\"4cc9725c953f57f8abe63b729e26125feac1be4e\"",
     26 		"\"platform/tools/external/gradle\"",
     27 		"\"jeffrey.lebowski (a] google.com\"",
     28 		"\"Take any rug in the house\"",
     29 		"\"Global\"",
     30 	}
     31 	assert.Equal(t, expected, csvRow, "Strings should be equal")
     32 }
     33 
     34 func TestCommitEntityToCSVHeader(t *testing.T) {
     35 	assert.Equal(
     36 		t,
     37 		[]string{
     38 			"Date",
     39 			"Commit",
     40 			"Downstream Project",
     41 			"Author",
     42 			"Subject",
     43 			"Project Type",
     44 		},
     45 		CommitCSVHeader(),
     46 		"Strings should be equal",
     47 	)
     48 }
     49 
     50 func TestCommitEntitiesToCSVRows(t *testing.T) {
     51 	commitRow := e.AnalyzedCommitRow{
     52 		CommitRow: e.CommitRow{
     53 			Date:              "2018/03/19",
     54 			Commit:            "4cc9725c953f57f8abe63b729e26125feac1be4e",
     55 			DownstreamProject: "platform/tools/external/gradle",
     56 			Author:            "jeffrey.lebowski (a] google.com",
     57 			Subject:           "Take any rug in the house",
     58 		},
     59 		Type: c.Global,
     60 	}
     61 
     62 	rows := CommitEntitiesToCSVRows(
     63 		[]e.AnalyzedCommitRow{
     64 			commitRow,
     65 			commitRow,
     66 		},
     67 	)
     68 	assert.Equal(t, 2, len(rows), "2 rows should be generated")
     69 }
     70