-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
REPORTING: improve cli report and added unit tests (#7)
* add reporting option to show culmative month * add images to readme page * small change to cli report output * make images in readme smaller * add test for cli markdown report
- Loading branch information
jeff-knurek
authored
Sep 26, 2020
1 parent
3fdac91
commit 1a2fb14
Showing
8 changed files
with
157 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
package reporting | ||
|
||
import ( | ||
"strings" | ||
"testing" | ||
"time" | ||
) | ||
|
||
func TestTextCalendar(t *testing.T) { | ||
dec, _ := time.Parse("2006-01-02 15:04", "2020-12-31 9:59") | ||
jan, _ := time.Parse("2006-01-02 15:04", "2021-01-02 9:59") | ||
tests := []struct { | ||
name string | ||
data Years | ||
t time.Time | ||
want string | ||
}{ | ||
{ | ||
name: "one month", | ||
data: Years{"2020": {"December": {"27": 420, "30": 120, "31": 120}}}, | ||
t: dec, | ||
want: strings.Replace(`December | ||
| Sun | Mon | Tue | Wed | Thu | Fri | Sat | | ||
|----:|----:|----:|----:|----:|----:|----:| | ||
| | | 0 | 0 | 0 | 0 | 0 | | ||
| 0 | 0 | 0 | 0 | 0 | 0 | 0 | | ||
| 0 | 0 | 0 | 0 | 0 | 0 | 0 | | ||
| 0 | 0 | 0 | 0 | 0 | 0 | 0 | | ||
| 7.0 | 0 | 0 | 2.0 | 2.0 | | |`, "\t", "", -1), | ||
}, | ||
{ | ||
name: "no data this month", | ||
data: Years{"2020": {"October": {"27": 420, "30": 120, "31": 120}}}, | ||
t: dec, | ||
want: "--no data tracked for this month--", | ||
}, | ||
{ | ||
name: "two months", | ||
data: Years{"2020": {"December": {"27": 420, "30": 120}}, "2021": {"January": {"1": 120, "2": 120}}}, | ||
t: jan, | ||
want: strings.Replace(`January | ||
| Sun | Mon | Tue | Wed | Thu | Fri | Sat | | ||
|----:|----:|----:|----:|----:|----:|----:| | ||
| | | | | | 2.0 | 2.0 | | ||
| . | . | . | . | . | . | . | | ||
| . | . | . | . | . | . | . | | ||
| . | . | . | . | . | . | . | | ||
| . | . | . | . | . | . | . | | ||
| . | | | | | | |`, "\t", "", -1), | ||
}, | ||
} | ||
for _, tt := range tests { | ||
t.Run(tt.name, func(t *testing.T) { | ||
got := textCalendar(tt.data, tt.t) | ||
if got != tt.want { | ||
t.Errorf("textCalendar() \nGot:\n%v,\nwant:\n%v\n", got, tt.want) | ||
} | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters