Skip to content

Commit 4a78289

Browse files
authored
Merge pull request #15 from attogram/fix/config-format-error
fix(config): Correct formatting error in config.dist.sh
2 parents 1a6059d + 2588f4e commit 4a78289

2 files changed

Lines changed: 14 additions & 0 deletions

File tree

dashboard.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,8 @@ else
260260
261261
if ($5 == "null") {
262262
printf "{\"date\":\"%s\",\"module\":\"%s\",\"channels\":\"%s\",\"namespace\":\"%s\",\"value\":null}", $1, $2, $3, $4
263+
} else if ($5 ~ /^[0-9]+$/) {
264+
printf "{\"date\":\"%s\",\"module\":\"%s\",\"channels\":\"%s\",\"namespace\":\"%s\",\"value\":%s}", $1, $2, $3, $4, $5
263265
} else {
264266
printf "{\"date\":\"%s\",\"module\":\"%s\",\"channels\":\"%s\",\"namespace\":\"%s\",\"value\":\"%s\"}", $1, $2, $3, $4, $5
265267
}

test/dashboard.bats

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,18 @@ teardown() {
5151
echo "$output" | jq -e '.[0] | has("date") and has("module") and has("value")' > /dev/null
5252
}
5353

54+
@test "bugfix: json output should have correct numeric types" {
55+
run ./dashboard.sh -f json
56+
[ "$status" -eq 0 ]
57+
# Check that a known numeric value is a number, not a string
58+
github_stars_value=$(echo "$output" | jq '.[] | select(.module == "github" and .channels == "stars" and .namespace == "repo.attogram.base") | .value')
59+
[ "$(jq 'type' <<< "$github_stars_value")" = '"number"' ]
60+
61+
# Check that a known numeric value from another module is also a number
62+
hackernews_karma_value=$(echo "$output" | jq '.[] | select(.module == "hackernews") | .value')
63+
[ "$(jq 'type' <<< "$hackernews_karma_value")" = '"number"' ]
64+
}
65+
5466
@test "integration: xml output should contain root element and metric data" {
5567
run ./dashboard.sh -f xml
5668
[ "$status" -eq 0 ]

0 commit comments

Comments
 (0)