Skip to content

Commit 99264e9

Browse files
johnkeepinggitster
authored andcommitted
t6300: add tests for "-local" date formats
Signed-off-by: John Keeping <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent db7bae2 commit 99264e9

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

t/t6300-for-each-ref.sh

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,10 @@ test_expect_success 'Check format "default" formatted date fields output' '
180180
"Tue Jul 4 01:18:45 2006 +0200"
181181
'
182182

183+
test_expect_success 'Check format "default-local" date fields output' '
184+
test_date default-local "Mon Jul 3 23:18:43 2006" "Mon Jul 3 23:18:44 2006" "Mon Jul 3 23:18:45 2006"
185+
'
186+
183187
# Don't know how to do relative check because I can't know when this script
184188
# is going to be run and can't fake the current time to git, and hence can't
185189
# provide expected output. Instead, I'll just make sure that "relative"
@@ -190,10 +194,22 @@ test_expect_success 'Check format "relative" date fields output' '
190194
git for-each-ref --shell --format="%(refname) %(taggerdate:$f)" refs/tags) >actual
191195
'
192196

197+
# We just check that this is the same as "relative" for now.
198+
test_expect_success 'Check format "relative-local" date fields output' '
199+
test_date relative-local \
200+
"$(git for-each-ref --format="%(committerdate:relative)" refs/heads)" \
201+
"$(git for-each-ref --format="%(authordate:relative)" refs/heads)" \
202+
"$(git for-each-ref --format="%(taggerdate:relative)" refs/tags)"
203+
'
204+
193205
test_expect_success 'Check format "short" date fields output' '
194206
test_date short 2006-07-04 2006-07-04 2006-07-04
195207
'
196208

209+
test_expect_success 'Check format "short-local" date fields output' '
210+
test_date short-local 2006-07-03 2006-07-03 2006-07-03
211+
'
212+
197213
test_expect_success 'Check format "local" date fields output' '
198214
test_date local \
199215
"Mon Jul 3 23:18:43 2006" \
@@ -208,17 +224,29 @@ test_expect_success 'Check format "iso8601" date fields output' '
208224
"2006-07-04 01:18:45 +0200"
209225
'
210226

227+
test_expect_success 'Check format "iso8601-local" date fields output' '
228+
test_date iso8601-local "2006-07-03 23:18:43 +0000" "2006-07-03 23:18:44 +0000" "2006-07-03 23:18:45 +0000"
229+
'
230+
211231
test_expect_success 'Check format "rfc2822" date fields output' '
212232
test_date rfc2822 \
213233
"Tue, 4 Jul 2006 01:18:43 +0200" \
214234
"Tue, 4 Jul 2006 01:18:44 +0200" \
215235
"Tue, 4 Jul 2006 01:18:45 +0200"
216236
'
217237

238+
test_expect_success 'Check format "rfc2822-local" date fields output' '
239+
test_date rfc2822-local "Mon, 3 Jul 2006 23:18:43 +0000" "Mon, 3 Jul 2006 23:18:44 +0000" "Mon, 3 Jul 2006 23:18:45 +0000"
240+
'
241+
218242
test_expect_success 'Check format "raw" date fields output' '
219243
test_date raw "1151968723 +0200" "1151968724 +0200" "1151968725 +0200"
220244
'
221245

246+
test_expect_success 'Check format "raw-local" date fields output' '
247+
test_date raw-local "1151968723 +0000" "1151968724 +0000" "1151968725 +0000"
248+
'
249+
222250
test_expect_success 'Check format of strftime date fields' '
223251
echo "my date is 2006-07-04" >expected &&
224252
git for-each-ref \
@@ -227,6 +255,14 @@ test_expect_success 'Check format of strftime date fields' '
227255
test_cmp expected actual
228256
'
229257

258+
test_expect_success 'Check format of strftime-local date fields' '
259+
echo "my date is 2006-07-03" >expected &&
260+
git for-each-ref \
261+
--format="%(authordate:format-local:my date is %Y-%m-%d)" \
262+
refs/heads >actual &&
263+
test_cmp expected actual
264+
'
265+
230266
cat >expected <<\EOF
231267
refs/heads/master
232268
refs/remotes/origin/master

0 commit comments

Comments
 (0)