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