mirror of
https://github.com/ddworken/hishtory.git
synced 2024-11-22 16:24:00 +01:00
Try again to fix timezone test
This commit is contained in:
parent
c52a7f4ae6
commit
b92087fc1d
@ -145,7 +145,10 @@ func init() {
|
||||
|
||||
func keepReleaseVersionUpToDate() {
|
||||
for {
|
||||
updateReleaseVersion()
|
||||
err := updateReleaseVersion()
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
}
|
||||
time.Sleep(10 * time.Minute)
|
||||
}
|
||||
}
|
||||
@ -154,31 +157,28 @@ type releaseInfo struct {
|
||||
Name string `json:"name"`
|
||||
}
|
||||
|
||||
func updateReleaseVersion() {
|
||||
func updateReleaseVersion() error {
|
||||
resp, err := http.Get("https://api.github.com/repos/ddworken/hishtory/releases/latest")
|
||||
if err != nil {
|
||||
fmt.Printf("failed to get latest release version: %v\n", err)
|
||||
return
|
||||
return fmt.Errorf("failed to get latest release version: %v\n", err)
|
||||
}
|
||||
respBody, err := ioutil.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
fmt.Printf("failed to read github API response body: %v\n", err)
|
||||
return
|
||||
return fmt.Errorf("failed to read github API response body: %v\n", err)
|
||||
}
|
||||
if resp.StatusCode == 403 && strings.Contains(string(respBody), "API rate limit exceeded for ") {
|
||||
// cannot update ReleaseVersion because we exceeded the rate limit, fail silently
|
||||
return
|
||||
return nil
|
||||
}
|
||||
if resp.StatusCode != 200 {
|
||||
fmt.Printf("failed to call github API, status_code=%d, body=%#v\n", resp.StatusCode, string(respBody))
|
||||
return
|
||||
return fmt.Errorf("failed to call github API, status_code=%d, body=%#v\n", resp.StatusCode, string(respBody))
|
||||
}
|
||||
var info releaseInfo
|
||||
err = json.Unmarshal(respBody, &info)
|
||||
if err != nil {
|
||||
fmt.Printf("failed to parse github API response: %v", err)
|
||||
return fmt.Errorf("failed to parse github API response: %v", err)
|
||||
}
|
||||
ReleaseVersion = info.Name
|
||||
return nil
|
||||
}
|
||||
|
||||
func InitDB() {
|
||||
|
@ -110,3 +110,5 @@ func TestESubmitThenQuery(t *testing.T) {
|
||||
t.Fatalf("Expected to retrieve 2 entries, found %d", len(retrievedEntries))
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: Maybe a test for updateReleaseVersion
|
||||
|
@ -53,7 +53,7 @@ func TestBuildHistoryEntry(t *testing.T) {
|
||||
if entry.Command != "ls /" {
|
||||
t.Fatalf("history entry has unexpected command: %v", entry.Command)
|
||||
}
|
||||
if !strings.HasPrefix(entry.StartTime.Format(time.RFC3339), "2022-01-09T") {
|
||||
if !strings.HasPrefix(entry.StartTime.Format(time.RFC3339), "2022-01-09T") && !strings.HasPrefix(entry.StartTime.Format(time.RFC3339), "2022-01-10T") {
|
||||
t.Fatalf("history entry has incorrect date in the start time: %v", entry.StartTime.Format(time.RFC3339))
|
||||
}
|
||||
if entry.StartTime.Unix() != 1641774958 {
|
||||
|
Loading…
Reference in New Issue
Block a user