@@ -156,7 +156,7 @@ resource "gitlab_deploy_token" "foo" {
156156 name = "deployToken-%d"
157157 username = "my-username"
158158
159- expires_at = "2021-03-14T07:20:50Z "
159+ expires_at = "2021-03-14T07:20:50.000Z "
160160
161161 scopes = [
162162 "read_registry",
@@ -165,3 +165,46 @@ resource "gitlab_deploy_token" "foo" {
165165}
166166 ` , rInt , rInt )
167167}
168+
169+ type expiresAtSuppressFuncTest struct {
170+ description string
171+ old string
172+ new string
173+ expected bool
174+ }
175+
176+ func TestExpiresAtSuppressFunc (t * testing.T ) {
177+ testcases := []expiresAtSuppressFuncTest {
178+ {
179+ description : "same dates without millis" ,
180+ old : "2025-03-14T00:00:00Z" ,
181+ new : "2025-03-14T00:00:00Z" ,
182+ expected : true ,
183+ }, {
184+ description : "different date without millis" ,
185+ old : "2025-03-14T00:00:00Z" ,
186+ new : "2025-03-14T11:11:11Z" ,
187+ expected : false ,
188+ }, {
189+ description : "same date with and without millis" ,
190+ old : "2025-03-14T00:00:00Z" ,
191+ new : "2025-03-14T00:00:00.000Z" ,
192+ expected : true ,
193+ }, {
194+ description : "cannot parse new date" ,
195+ old : "2025-03-14T00:00:00Z" ,
196+ new : "invalid-date" ,
197+ expected : false ,
198+ },
199+ }
200+
201+ for _ , test := range testcases {
202+ t .Run (test .description , func (t * testing.T ) {
203+ actual := expiresAtSuppressFunc ("" , test .old , test .new , nil )
204+ if actual != test .expected {
205+ t .Fatalf ("FAIL\n \t old: %s, new: %s\n \t expected: %t\n \t actual: %t" ,
206+ test .old , test .new , test .expected , actual )
207+ }
208+ })
209+ }
210+ }
0 commit comments