tests a go
This commit is contained in:
@@ -52,11 +52,12 @@ func TestGetContributions(t *testing.T) {
|
||||
"a": ledger.Balance{"y": 1},
|
||||
},
|
||||
"2001-03": ledger.Balances{
|
||||
"b": ledger.Balance{"z": 2},
|
||||
"b": ledger.Balance{"z": 4},
|
||||
},
|
||||
}
|
||||
|
||||
got := getContributions(input)
|
||||
t.Logf("%+v", got)
|
||||
if len(got) != 2 {
|
||||
t.Error(len(got))
|
||||
}
|
||||
@@ -69,9 +70,9 @@ func TestGetContributions(t *testing.T) {
|
||||
} else if len(got["a"][1]) != 2 {
|
||||
t.Error(got["a"][1])
|
||||
} else if got["a"][1]["x"] != -1 {
|
||||
t.Error(got["a"][1]["x"])
|
||||
t.Error(got["a"][1])
|
||||
} else if got["a"][1]["y"] != 1 {
|
||||
t.Error(got["a"][1]["y"])
|
||||
t.Error(got["a"][1])
|
||||
}
|
||||
|
||||
if len(got["b"]) != 2 {
|
||||
@@ -81,8 +82,26 @@ func TestGetContributions(t *testing.T) {
|
||||
} else if got["b"][0]["z"] != 1 {
|
||||
t.Error(got["b"][0])
|
||||
} else if len(got["b"][1]) != 1 {
|
||||
t.Error(got["b"])
|
||||
} else if got["b"][1]["z"] != 3 {
|
||||
t.Error(got["b"][1])
|
||||
} else if got["b"][1]["z"] != 1 {
|
||||
t.Error(got["b"][1]["z"])
|
||||
}
|
||||
}
|
||||
|
||||
func TestGetMonthlyContributionRate(t *testing.T) {
|
||||
input := []ledger.Balance{
|
||||
ledger.Balance{"x": 2},
|
||||
ledger.Balance{"x": 4},
|
||||
ledger.Balance{"y": 3},
|
||||
}
|
||||
got := getMonthlyContributionRate(input)
|
||||
if len(got) != 2 {
|
||||
t.Error(got)
|
||||
}
|
||||
if got["x"] != 2 {
|
||||
t.Error(got["x"])
|
||||
}
|
||||
if got["y"] != 1 {
|
||||
t.Error(got["y"])
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user