(t *testing.T)
| 127 | } |
| 128 | |
| 129 | func TestConvertStringToTime(t *testing.T) { |
| 130 | testCases := []struct { |
| 131 | name string |
| 132 | input string |
| 133 | output time.Time |
| 134 | err error |
| 135 | }{ |
| 136 | { |
| 137 | name: "Valid time string", |
| 138 | input: "2023-03-01T12:30:00+0000", |
| 139 | output: time.Date(2023, 3, 1, 12, 30, 0, 0, time.UTC).Local(), |
| 140 | err: nil, |
| 141 | }, |
| 142 | { |
| 143 | name: "Valid date string", |
| 144 | input: "2023-03-01", |
| 145 | output: time.Date(2023, 3, 1, 0, 0, 0, 0, time.UTC), |
| 146 | err: nil, |
| 147 | }, |
| 148 | { |
| 149 | name: "Invalid time string", |
| 150 | input: "invalid", |
| 151 | output: time.Time{}, |
| 152 | err: fmt.Errorf("parsing time \"invalid\" as \"2006-01-02T15:04:05Z07:00\": cannot parse \"invalid\" as \"2006\""), |
| 153 | }, |
| 154 | } |
| 155 | for _, tc := range testCases { |
| 156 | t.Run(tc.name, func(t *testing.T) { |
| 157 | output, err := ConvertStringToTime(tc.input) |
| 158 | if !reflect.DeepEqual(tc.output, output) { |
| 159 | t.Errorf("Expected output to be %v, but got %v", tc.output, output) |
| 160 | } |
| 161 | assert.Equal(t, fmt.Sprintf("%v", err), fmt.Sprintf("%v", tc.err), "Expected error to be %v, but got %v", tc.err, err) |
| 162 | }) |
| 163 | } |
| 164 | } |
| 165 | |
| 166 | func TestIsNonDateString(t *testing.T) { |
| 167 | testCases := []struct { |
nothing calls this directly
no test coverage detected