Skip to content

Commit 7c03fa7

Browse files
committed
feat: add date of birth (dob) field to Res struct and update related tests
1 parent 44fbfc8 commit 7c03fa7

File tree

4 files changed

+13
-2
lines changed

4 files changed

+13
-2
lines changed

call-profile/main_test.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,7 @@ func TestHandlerIntegration(t *testing.T) {
319319
"githubId": "johndoe",
320320
"linkedin": "johndoe",
321321
"website": "https://johndoe.com",
322+
"dob": "1990-01-15",
322323
},
323324
mockServer: func() *httptest.Server {
324325
return httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
@@ -337,7 +338,8 @@ func TestHandlerIntegration(t *testing.T) {
337338
"designation": "Developer",
338339
"github_id": "johndoe",
339340
"linkedin_id": "johndoe",
340-
"website": "https://johndoe.com"
341+
"website": "https://johndoe.com",
342+
"dob": "1990-01-15"
341343
}`))
342344
}
343345
}))
@@ -522,6 +524,7 @@ func TestHandlerWithRealFirestore(t *testing.T) {
522524
"githubId": "integrationtest",
523525
"linkedin": "integrationtest",
524526
"website": "https://integrationtest.com",
527+
"dob": "1992-05-20",
525528
}
526529

527530
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
@@ -540,7 +543,8 @@ func TestHandlerWithRealFirestore(t *testing.T) {
540543
"designation": "Tester",
541544
"github_id": "integrationtest",
542545
"linkedin_id": "integrationtest",
543-
"website": "https://integrationtest.com"
546+
"website": "https://integrationtest.com",
547+
"dob": "1992-05-20"
544548
}`))
545549
}
546550
}))

call-profile/testdata.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,7 @@ var ResValidationTests = []struct {
163163
TwitterId: "johndoe",
164164
InstagramId: "johndoe",
165165
Website: "https://johndoe.com",
166+
DOB: "1990-01-15",
166167
},
167168
IsValid: true,
168169
Description: "Complete valid Res struct",
@@ -293,3 +294,4 @@ var EmptyUserIdTests = []struct {
293294
Description: "Null userId should return skip message",
294295
},
295296
}
297+

layer/utils/constants.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ type Res struct {
2828
TwitterId string `json:"twitter_id"`
2929
InstagramId string `json:"instagram_id"`
3030
Website string `json:"website"`
31+
DOB string `json:"dob"`
3132
}
3233

3334
type Diff struct {
@@ -46,6 +47,7 @@ type Diff struct {
4647
TwitterId string `firestore:"twitter_id,omitempty"`
4748
InstagramId string `firestore:"instagram_id,omitempty"`
4849
Website string `firestore:"website,omitempty"`
50+
DOB string `firestore:"dob,omitempty"`
4951
}
5052

5153
type Claims struct {
@@ -99,5 +101,6 @@ func diffToMap(diff Diff) map[string]interface{} {
99101
"twitter_id": diff.TwitterId,
100102
"instagram_id": diff.InstagramId,
101103
"website": diff.Website,
104+
"dob": diff.DOB,
102105
}
103106
}

layer/utils/validation.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ func resToDiff(res Res, userId string) Diff {
2626
TwitterId: res.TwitterId,
2727
InstagramId: res.InstagramId,
2828
Website: res.Website,
29+
DOB: res.DOB,
2930
}
3031
}
3132

@@ -43,6 +44,7 @@ func DiffToRes(diff Diff) Res {
4344
TwitterId: diff.TwitterId,
4445
InstagramId: diff.InstagramId,
4546
Website: diff.Website,
47+
DOB: diff.DOB,
4648
}
4749
}
4850

0 commit comments

Comments
 (0)