-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(client.go): correctly fetch build number info
The endpoint listed for build number data is currently broken and never updates. Using this workaround should allow the tool to check for build number changes so it can update the cache, but also when the endpoint is no longer broken, be easily removed.
- Loading branch information
Showing
2 changed files
with
72 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package main | ||
|
||
import ( | ||
"errors" | ||
"testing" | ||
) | ||
|
||
func TestParseBuildNumber(t *testing.T) { | ||
tests := []struct { | ||
name string | ||
input string | ||
expected int | ||
err error | ||
}{ | ||
{"Valid input is parsed with no errors", "10", 10, nil}, | ||
{"Empty input data returns zero and an error", "", 0, errors.New("Cannot parse empty build number data")}, | ||
{"Invalid input returns zero and an error", "abc", 0, errors.New("strconv.Atoi: parsing \"abc\": invalid syntax")}, | ||
} | ||
|
||
for _, tt := range tests { | ||
t.Run(tt.name, func(t *testing.T) { | ||
result, err := parseBuildNumber(tt.input) | ||
if result != tt.expected { | ||
t.Errorf("Expected %d, but got %d", tt.expected, result) | ||
} | ||
if err != nil && err.Error() != tt.err.Error() { | ||
t.Errorf("Expected error %v, but got %v", tt.err, err) | ||
} | ||
}) | ||
} | ||
} |