From 180ff62da6047c89dcac33df45920088f2b56098 Mon Sep 17 00:00:00 2001 From: Rick Olson Date: Wed, 2 Sep 2015 10:43:52 -0600 Subject: [PATCH] merge all batch tests into a single test func --- lfs/config_test.go | 88 +++++++++------------------------------------- 1 file changed, 17 insertions(+), 71 deletions(-) diff --git a/lfs/config_test.go b/lfs/config_test.go index 057486c6..00b8bf0e 100644 --- a/lfs/config_test.go +++ b/lfs/config_test.go @@ -279,81 +279,27 @@ func TestConcurrentTransfersNegativeValue(t *testing.T) { assert.Equal(t, 3, n) } -func TestBatchTrue(t *testing.T) { - config := &Configuration{ - gitConfig: map[string]string{ - "lfs.batch": "true", - }, +func TestBatch(t *testing.T) { + tests := map[string]bool{ + "true": true, + "1": true, + "42": true, + "-1": true, + "": true, + "0": false, + "false": false, + "elephant": false, } - v := config.BatchTransfer() - assert.Equal(t, true, v) -} + for value, expected := range tests { + config := &Configuration{ + gitConfig: map[string]string{"lfs.batch": value}, + } -func TestBatchNumeric1IsTrue(t *testing.T) { - config := &Configuration{ - gitConfig: map[string]string{ - "lfs.batch": "1", - }, + if actual := config.BatchTransfer(); actual != expected { + t.Errorf("lfs.batch %q == %v, not %v", value, actual, expected) + } } - - v := config.BatchTransfer() - assert.Equal(t, true, v) -} - -func TestBatchNumeric0IsFalse(t *testing.T) { - config := &Configuration{ - gitConfig: map[string]string{ - "lfs.batch": "0", - }, - } - - v := config.BatchTransfer() - assert.Equal(t, false, v) -} - -func TestBatchOtherNumericsAreTrue(t *testing.T) { - config := &Configuration{ - gitConfig: map[string]string{ - "lfs.batch": "42", - }, - } - - v := config.BatchTransfer() - assert.Equal(t, true, v) -} - -func TestBatchNegativeNumericsAreTrue(t *testing.T) { - config := &Configuration{ - gitConfig: map[string]string{ - "lfs.batch": "-1", - }, - } - - v := config.BatchTransfer() - assert.Equal(t, true, v) -} - -func TestBatchNonBooleanIsFalse(t *testing.T) { - config := &Configuration{ - gitConfig: map[string]string{ - "lfs.batch": "elephant", - }, - } - - v := config.BatchTransfer() - assert.Equal(t, false, v) -} - -func TestBatchPresentButBlankIsTrue(t *testing.T) { - config := &Configuration{ - gitConfig: map[string]string{ - "lfs.batch": "", - }, - } - - v := config.BatchTransfer() - assert.Equal(t, true, v) } func TestBatchAbsentIsTrue(t *testing.T) {