forked from ProTip/aws-elk-billing
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main_test.go
47 lines (42 loc) · 1.08 KB
/
main_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package main
import (
_ "fmt"
"testing"
)
func TestCostAllocationMatcher(t *testing.T) {
if !monthlyCostAllocationMatcher.MatchString("376681487066-aws-cost-allocation-2013-06.csv") {
t.Fail()
}
}
func TestDetailedBillingWithResourcesMatcher(t *testing.T) {
if !detailedBillingWithResourcesMatcher.MatchString("376681487066-aws-billing-detailed-line-items-with-resources-and-tags-2014-03.csv") {
t.Fail()
}
}
func TestBillingReportTypeString(t *testing.T) {
report := &BillingReport{}
report.ReportType = MonthlyCostAllocation
if report.TypeString() != "aws_billing_monthly" {
t.Fail()
}
report.ReportType = DetailedBillingWithResourcesAndTags
if report.TypeString() != "aws_billing_hourly" {
t.Fail()
}
}
func TestParseReport(t *testing.T) {
in := make(chan []string)
out := make(chan map[string]interface{})
report := OpenBillingReport("test-2014-06.csv")
report.Mapper = FieldMapper{
"LinkedAccountId": {
"041869798014": {
"AccountName": "MYOB Advanced",
},
},
}
go ParseRecord(in, out, report)
values, _ := report.csvReader.Read()
in <- values
close(in)
}