Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added test case to cover fetching observations from sql when the requested date has a hyphen #1460

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions internal/server/v2/observation/golden/direct/2024-09.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"by_variable": {
"var_with_hyphenated_date": {
"by_entity": {
"country/USA": {
"ordered_facets": [
{
"facet_id": "2921750529",
"observations": [
{
"date": "2024-09",
"value": 3
}
],
"obs_count": 1,
"earliest_date": "2024-09",
"latest_date": "2024-09"
}
]
}
}
}
},
"facets": {
"2921750529": {
"import_name": "Custom Prov",
"provenance_url": "custom.datacommons.org"
}
}
}
9 changes: 9 additions & 0 deletions internal/server/v2/observation/golden/direct_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,15 @@ func TestFetchDirect(t *testing.T) {
nil,
"2010.json",
},
{
[]string{
"var_with_hyphenated_date",
},
[]string{"country/USA"},
"2024-09",
nil,
"2024-09.json",
},
{
[]string{
"Area_Farm",
Expand Down
Binary file modified test/datacommons.db
Binary file not shown.
4 changes: 4 additions & 0 deletions test/observations.csv
Original file line number Diff line number Diff line change
Expand Up @@ -80,3 +80,7 @@ country/USA,var_with_props,2023,1,custom,USD,,,,
country/GBR,var_with_props,2023,2,custom,USD,,,,
country/USA,var_with_props,2023,3,custom,GBP,,,,
country/GBR,var_with_props,2023,4,custom,GBP,,,,
country/USA,var_with_hyphenated_date,2024-07,1,custom,,,,,
country/USA,var_with_hyphenated_date,2024-08,2,custom,,,,,
country/USA,var_with_hyphenated_date,2024-09,3,custom,,,,,
country/USA,var_with_hyphenated_date,2024-10,4,custom,,,,,