fix(test): check errors instead of discarding with bare _
Replace bare _ error discards with t.Fatalf checks across sqlstore_test, crypto_test, server_test, and checker_test.
This commit was merged in pull request #152.
This commit is contained in:
@@ -75,8 +75,14 @@ func TestEncryptorUniqueCiphertexts(t *testing.T) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
a, _ := enc.Encrypt("same")
|
||||
b, _ := enc.Encrypt("same")
|
||||
a, err := enc.Encrypt("same")
|
||||
if err != nil {
|
||||
t.Fatalf("first encrypt: %v", err)
|
||||
}
|
||||
b, err := enc.Encrypt("same")
|
||||
if err != nil {
|
||||
t.Fatalf("second encrypt: %v", err)
|
||||
}
|
||||
if a == b {
|
||||
t.Error("two encryptions of same plaintext should produce different ciphertexts")
|
||||
}
|
||||
|
||||
@@ -343,7 +343,10 @@ func TestDeleteSiteCascade(t *testing.T) {
|
||||
if err := s.AddSite(context.Background(), site); err != nil {
|
||||
t.Fatalf("AddSite: %v", err)
|
||||
}
|
||||
sites, _ := s.GetSites(context.Background())
|
||||
sites, err := s.GetSites(context.Background())
|
||||
if err != nil {
|
||||
t.Fatalf("GetSites: %v", err)
|
||||
}
|
||||
siteID := sites[0].ID
|
||||
|
||||
if err := s.SaveCheck(context.Background(), siteID, 1000, true); err != nil {
|
||||
@@ -366,17 +369,26 @@ func TestDeleteSiteCascade(t *testing.T) {
|
||||
t.Fatalf("DeleteSite: %v", err)
|
||||
}
|
||||
|
||||
history, _ := s.LoadAllHistory(context.Background(), 100)
|
||||
history, err := s.LoadAllHistory(context.Background(), 100)
|
||||
if err != nil {
|
||||
t.Fatalf("LoadAllHistory: %v", err)
|
||||
}
|
||||
if len(history[siteID]) != 0 {
|
||||
t.Errorf("expected 0 check_history rows, got %d", len(history[siteID]))
|
||||
}
|
||||
|
||||
changes, _ := s.GetStateChanges(context.Background(), siteID, 100)
|
||||
changes, err := s.GetStateChanges(context.Background(), siteID, 100)
|
||||
if err != nil {
|
||||
t.Fatalf("GetStateChanges: %v", err)
|
||||
}
|
||||
if len(changes) != 0 {
|
||||
t.Errorf("expected 0 state_changes rows, got %d", len(changes))
|
||||
}
|
||||
|
||||
windows, _ := s.GetActiveMaintenanceWindows(context.Background())
|
||||
windows, err := s.GetActiveMaintenanceWindows(context.Background())
|
||||
if err != nil {
|
||||
t.Fatalf("GetActiveMaintenanceWindows: %v", err)
|
||||
}
|
||||
for _, w := range windows {
|
||||
if w.MonitorID == siteID {
|
||||
t.Errorf("orphaned maintenance window found: id=%d", w.ID)
|
||||
|
||||
Reference in New Issue
Block a user