@@ -15,7 +15,7 @@ import (
1515 "github.com/m-lab/go/pretty"
1616)
1717
18- func setupNDT7InMemoryParser (t * testing.T , testName string ) (* schema.NDT7ResultRow , error ) {
18+ func setupNDT7InMemoryParser (t * testing.T , testName string ) (* schema.NDT7ResultRow , int64 , error ) {
1919 ins := newInMemorySink ()
2020 n := parser .NewNDT7ResultParser (ins , "test" , "_suffix" )
2121
@@ -31,14 +31,14 @@ func setupNDT7InMemoryParser(t *testing.T, testName string) (*schema.NDT7ResultR
3131 }
3232 err = n .ParseAndInsert (meta , testName , resultData )
3333 if err != nil {
34- return nil , err
34+ return nil , 0 , err
3535 }
3636 if n .Accepted () != 1 {
3737 t .Fatal ("Failed to insert snaplog data." , ins )
3838 }
3939 n .Flush ()
4040 row := ins .data [0 ].(* schema.NDT7ResultRow )
41- return row , err
41+ return row , int64 ( len ( resultData )), err
4242}
4343
4444func TestNDT7ResultParser_ParseAndInsert (t * testing.T ) {
@@ -58,7 +58,7 @@ func TestNDT7ResultParser_ParseAndInsert(t *testing.T) {
5858 }
5959 for _ , tt := range tests {
6060 t .Run (tt .name , func (t * testing.T ) {
61- row , err := setupNDT7InMemoryParser (t , tt .testName )
61+ row , size , err := setupNDT7InMemoryParser (t , tt .testName )
6262 if (err != nil ) != tt .wantErr {
6363 t .Errorf ("NDT7ResultParser.ParseAndInsert() error = %v, wantErr %v" , err , tt .wantErr )
6464 }
@@ -82,6 +82,7 @@ func TestNDT7ResultParser_ParseAndInsert(t *testing.T) {
8282 Filename : "ndt7-download-20200318T000657.568382877Z.ndt-knwp4_1583603744_000000000000590E.json" ,
8383 Priority : 0 ,
8484 GitCommit : "12345678" ,
85+ FileSize : size ,
8586 }
8687 if diff := deep .Equal (row .Parser , expPI ); diff != nil {
8788 pretty .Print (row .Parser )
@@ -121,6 +122,7 @@ func TestNDT7ResultParser_ParseAndInsert(t *testing.T) {
121122 Filename : "ndt7-upload-20200318T001352.496224022Z.ndt-knwp4_1583603744_0000000000005CF2.json" ,
122123 Priority : 0 ,
123124 GitCommit : "12345678" ,
125+ FileSize : size ,
124126 }
125127 if diff := deep .Equal (row .Parser , expPI ); diff != nil {
126128 t .Errorf ("NDT7ResultParser.ParseAndInsert() different summary: %s" , strings .Join (diff , "\n " ))
@@ -160,7 +162,7 @@ func TestNDT7ResultParser_ParseAndInsertUnsafe(t *testing.T) {
160162 }
161163 for _ , tt := range tests {
162164 t .Run (tt .name , func (t * testing.T ) {
163- row , err := setupNDT7InMemoryParser (t , tt .testName )
165+ row , _ , err := setupNDT7InMemoryParser (t , tt .testName )
164166 if (err != nil ) != tt .wantErr {
165167 t .Errorf ("NDT7ResultParser.ParseAndInsert() error = %v, wantErr %v" , err , tt .wantErr )
166168 }
0 commit comments