github.com/bcampbell/scrapeomat@v0.0.0-20220820232205-23e64141c89e/slurp/summary_test.go (about)

     1  package slurp
     2  
     3  import (
     4  	//	"fmt"
     5  	"reflect"
     6  	"testing"
     7  )
     8  
     9  func TestCookSummary(t *testing.T) {
    10  
    11  	inp := RawSummary{
    12  		"superschoolnews": {"2001-01-02": 19},
    13  		"dailyblah":       {"2001-01-01": 42, "2001-01-03": 102},
    14  	}
    15  
    16  	expect := &CookedSummary{
    17  		PubCodes: []string{"dailyblah", "superschoolnews"},
    18  		Days:     []string{"2001-01-01", "2001-01-02", "2001-01-03", "2001-01-04"},
    19  		Data: [][]int{
    20  			[]int{42, 0, 102, 0}, []int{0, 19, 0, 0},
    21  		},
    22  	}
    23  
    24  	got := CookSummary(inp, "2001-01-01", "2001-01-04")
    25  
    26  	if !reflect.DeepEqual(got, expect) {
    27  		t.Errorf(`CookSummary() failed (got %v", expected %v)`, got, expect)
    28  	}
    29  }