From d0e4228f9e208440891393e7e9728bc950e7a402 Mon Sep 17 00:00:00 2001 From: Andreas Deininger Date: Thu, 12 Dec 2024 20:56:15 +0100 Subject: [PATCH] Fix issues report from testifylint --- database_unit_test.go | 42 +++++++++++++++++++++--------------------- language_unit_test.go | 4 ++-- parser_unit_test.go | 8 ++++---- 3 files changed, 27 insertions(+), 27 deletions(-) diff --git a/database_unit_test.go b/database_unit_test.go index 423f2899..f09f81cd 100755 --- a/database_unit_test.go +++ b/database_unit_test.go @@ -427,87 +427,87 @@ func TestError_Value(t *testing.T) { c1 := Parse("") v1, e1 := c1.Value() require.NoError(t, e1) - assert.Equal(t, v1, nil) + assert.Nil(t, v1) c2 := NewDateTime(c1) v2, e2 := c2.Value() require.NoError(t, e2) - assert.Equal(t, v2, nil) + assert.Nil(t, v2) c3 := NewDateTimeMilli(c1) v3, e3 := c3.Value() require.NoError(t, e3) - assert.Equal(t, v3, nil) + assert.Nil(t, v3) c4 := NewDateTimeMicro(c1) v4, e4 := c4.Value() require.NoError(t, e4) - assert.Equal(t, v4, nil) + assert.Nil(t, v4) c5 := NewDateTimeNano(c1) v5, e5 := c5.Value() require.NoError(t, e5) - assert.Equal(t, v5, nil) + assert.Nil(t, v5) c6 := NewDate(c1) v6, e6 := c6.Value() require.NoError(t, e6) - assert.Equal(t, v6, nil) + assert.Nil(t, v6) c7 := NewDateMilli(c1) v7, e7 := c7.Value() require.NoError(t, e7) - assert.Equal(t, v7, nil) + assert.Nil(t, v7) c8 := NewDateMicro(c1) v8, e8 := c8.Value() require.NoError(t, e8) - assert.Equal(t, v8, nil) + assert.Nil(t, v8) c9 := NewDateNano(c1) v9, e9 := c9.Value() require.NoError(t, e9) - assert.Equal(t, v9, nil) + assert.Nil(t, v9) c10 := NewTime(c1) v10, e10 := c10.Value() require.NoError(t, e10) - assert.Equal(t, v10, nil) + assert.Nil(t, v10) c11 := NewTimeMilli(c1) v11, e11 := c11.Value() require.NoError(t, e11) - assert.Equal(t, v11, nil) + assert.Nil(t, v11) c12 := NewTimeMicro(c1) v12, e12 := c12.Value() require.NoError(t, e12) - assert.Equal(t, v12, nil) + assert.Nil(t, v12) c13 := NewTimeNano(c1) v13, e13 := c13.Value() require.NoError(t, e13) - assert.Equal(t, v13, nil) + assert.Nil(t, v13) c14 := NewTimestamp(c1) v14, e14 := c14.Value() require.NoError(t, e14) - assert.Equal(t, v14, nil) + assert.Nil(t, v14) c15 := NewTimestampMilli(c1) v15, e15 := c15.Value() require.NoError(t, e15) - assert.Equal(t, v15, nil) + assert.Nil(t, v15) c16 := NewTimestampMicro(c1) v16, e16 := c16.Value() require.NoError(t, e16) - assert.Equal(t, v16, nil) + assert.Nil(t, v16) c17 := NewTimestampNano(c1) v17, e17 := c17.Value() require.NoError(t, e17) - assert.Equal(t, v17, nil) + assert.Nil(t, v17) } type Person struct { @@ -907,10 +907,10 @@ func TestCarbon_Issue240(t *testing.T) { require.NoError(t, emptyErr) assert.Equal(t, "0001-01-01 00:00:00 +0000 UTC", person.Birthday1.StdTime().String()) assert.Equal(t, "0001-01-01 00:00:00 +0000 UTC", person.Birthday2.StdTime().String()) - assert.Equal(t, true, person.Birthday1.IsZero()) - assert.Equal(t, true, person.Birthday2.IsZero()) - assert.Equal(t, false, person.Birthday1.IsValid()) - assert.Equal(t, false, person.Birthday2.IsValid()) + assert.True(t, person.Birthday1.IsZero()) + assert.True(t, person.Birthday2.IsZero()) + assert.False(t, person.Birthday1.IsValid()) + assert.False(t, person.Birthday2.IsValid()) } // https://github.com/dromara/carbon/issues/243 diff --git a/language_unit_test.go b/language_unit_test.go index a47107c2..303154a8 100755 --- a/language_unit_test.go +++ b/language_unit_test.go @@ -88,8 +88,8 @@ func TestLanguage_SetResources1(t *testing.T) { for index, test := range tests { c1 := c.Parse(test.input1) c2 := c.Parse(test.input2) - assert.Nil(c1.Error) - assert.Nil(c2.Error) + assert.NoError(c1.Error) + assert.NoError(c2.Error) assert.Equal(test.expected, c1.DiffForHumans(c2), "Current test index is "+strconv.Itoa(index)) } } diff --git a/parser_unit_test.go b/parser_unit_test.go index ebef6e3f..183d0dde 100755 --- a/parser_unit_test.go +++ b/parser_unit_test.go @@ -147,13 +147,13 @@ func TestCarbon_ParseByLayout(t *testing.T) { } func TestError_ParseByLayout(t *testing.T) { - assert.NotNil(t, ParseByLayout("2020-08-05", "2006-03-04", "xxx").Error, "It should catch an exception in ParseByLayout") - assert.NotNil(t, ParseByLayout("xxx", "2006-03-04", PRC).Error, "It should catch an exception in ParseByLayout") + assert.Error(t, ParseByLayout("2020-08-05", "2006-03-04", "xxx").Error, "It should catch an exception in ParseByLayout") + assert.Error(t, ParseByLayout("xxx", "2006-03-04", PRC).Error, "It should catch an exception in ParseByLayout") } func TestError_ParseByFormat(t *testing.T) { - assert.NotNil(t, ParseByFormat("2020-08-05", "Y-m-d", "xxx").Error, "It should catch an exception in ParseByFormat()") - assert.NotNil(t, ParseByFormat("xxx", "Y-m-d", PRC).Error, "It should catch an exception in ParseByFormat") + assert.Error(t, ParseByFormat("2020-08-05", "Y-m-d", "xxx").Error, "It should catch an exception in ParseByFormat()") + assert.Error(t, ParseByFormat("xxx", "Y-m-d", PRC).Error, "It should catch an exception in ParseByFormat") } // https://github.com/dromara/carbon/issues/202