MCPcopy Create free account
hub / github.com/antonmedv/gitmal / TestHasEpochTimestamp

Function TestHasEpochTimestamp

pkg/gitdiff/file_header_test.go:711–766  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

709}
710
711func TestHasEpochTimestamp(t *testing.T) {
712 tests := map[string]struct {
713 Input string
714 Output bool
715 }{
716 "utcTimestamp": {
717 Input: "+++ file.txt\t1970-01-01 00:00:00 +0000\n",
718 Output: true,
719 },
720 "utcZoneWithColon": {
721 Input: "+++ file.txt\t1970-01-01 00:00:00 +00:00\n",
722 Output: true,
723 },
724 "utcZoneWithMilliseconds": {
725 Input: "+++ file.txt\t1970-01-01 00:00:00.000000 +00:00\n",
726 Output: true,
727 },
728 "westTimestamp": {
729 Input: "+++ file.txt\t1969-12-31 16:00:00 -0800\n",
730 Output: true,
731 },
732 "eastTimestamp": {
733 Input: "+++ file.txt\t1970-01-01 04:00:00 +0400\n",
734 Output: true,
735 },
736 "noTab": {
737 Input: "+++ file.txt 1970-01-01 00:00:00 +0000\n",
738 Output: false,
739 },
740 "invalidFormat": {
741 Input: "+++ file.txt\t1970-01-01T00:00:00Z\n",
742 Output: false,
743 },
744 "notEpoch": {
745 Input: "+++ file.txt\t2019-03-21 12:34:56.789 -0700\n",
746 Output: false,
747 },
748 "notTimestamp": {
749 Input: "+++ file.txt\trandom text\n",
750 Output: false,
751 },
752 "notTimestampShort": {
753 Input: "+++ file.txt\t0\n",
754 Output: false,
755 },
756 }
757
758 for name, test := range tests {
759 t.Run(name, func(t *testing.T) {
760 output := hasEpochTimestamp(test.Input)
761 if output != test.Output {
762 t.Errorf("incorrect output: expected %t, actual %t", test.Output, output)
763 }
764 })
765 }
766}

Callers

nothing calls this directly

Calls 2

hasEpochTimestampFunction · 0.85
ErrorfMethod · 0.80

Tested by

no test coverage detected