diff --git a/connection/mysql_test.go b/connection/mysql_test.go index c1e08330..b7067c15 100644 --- a/connection/mysql_test.go +++ b/connection/mysql_test.go @@ -7,6 +7,7 @@ import ( "github.com/go-sql-driver/mysql" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" + "github.com/stretchr/testify/require" "os" "sync" "sync/atomic" @@ -161,7 +162,7 @@ func TestDBWrapper_SqlBegin(t *testing.T) { func TestDBWrapper_SqlTransaction(t *testing.T) { dbw, err := NewDBWrapper(os.Getenv("ICINGADB_TEST_MYSQL")) - assert.NoError(t, err, "Is the MySQL server running?") + require.NoError(t, err, "Is the MySQL server running?") err = dbw.SqlTransaction(false, true, false, func(tx DbTransaction) error { return nil @@ -295,13 +296,13 @@ func TestGetConnectionCheckInterval(t *testing.T) { func TestDBWrapper_SqlFetchAll(t *testing.T) { dbw, err := NewDBWrapper(os.Getenv("ICINGADB_TEST_MYSQL")) - assert.NoError(t, err, "Is the MySQL server running?") + require.NoError(t, err, "Is the MySQL server running?") _, err = dbw.Db.Exec("CREATE TABLE testing0815 (id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, name varchar(255) NOT NULL)") - assert.NoError(t, err) + require.NoError(t, err) _, err = dbw.Db.Exec("INSERT INTO testing0815 (name) VALUES ('horst'), ('test')") - assert.NoError(t, err) + require.NoError(t, err) var res [][]interface{} done := make(chan bool) diff --git a/ha/ha_test.go b/ha/ha_test.go index ff3723db..64c5ee15 100644 --- a/ha/ha_test.go +++ b/ha/ha_test.go @@ -8,6 +8,7 @@ import ( "github.com/google/uuid" log "github.com/sirupsen/logrus" "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" "os" "sync" "testing" @@ -36,7 +37,7 @@ func createTestingHA(t *testing.T) *HA { ha.uid = uuid.MustParse("551bc748-94b2-4d27-b6a4-15c52aecfe85") _, err = ha.super.Dbw.SqlExec(mysqlTestObserver, "TRUNCATE TABLE icingadb_instance") - assert.NoError(t, err, "This test needs a working MySQL connection!") + require.NoError(t, err, "This test needs a working MySQL connection!") ha.logger = log.WithFields(log.Fields{ "context": "HA-Testing", @@ -52,14 +53,14 @@ func TestHA_InsertInstance(t *testing.T) { ha := createTestingHA(t) err := ha.insertInstance() - assert.NoError(t, err, "insertInstance should not return an error") + require.NoError(t, err, "insertInstance should not return an error") rows, err := ha.super.Dbw.SqlFetchAll(mysqlObservers.selectIdHeartbeatFromIcingadbInstanceByEnvironmentId, "SELECT id, heartbeat from icingadb_instance where environment_id = ? LIMIT 1", ha.super.EnvId, ) - assert.NoError(t, err, "There was an unexpected SQL error") + require.NoError(t, err, "There was an unexpected SQL error") assert.Equal(t, 1, len(rows), "There should be a row inserted") var theirUUID uuid.UUID @@ -75,13 +76,13 @@ func TestHA_checkResponsibility(t *testing.T) { assert.Equal(t, true, ha.isActive, "HA should be responsible, if no other instance is active") _, err := ha.super.Dbw.SqlExec(mysqlTestObserver, "TRUNCATE TABLE icingadb_instance") - assert.NoError(t, err, "This test needs a working MySQL connection!") + require.NoError(t, err, "This test needs a working MySQL connection!") _, err = ha.super.Dbw.SqlExec(mysqlObservers.insertIntoIcingadbInstance, "INSERT INTO icingadb_instance(id, environment_id, heartbeat, responsible) VALUES (?, ?, ?, 'y')", ha.uid[:], ha.super.EnvId, 0) - assert.NoError(t, err, "This test needs a working MySQL connection!") + require.NoError(t, err, "This test needs a working MySQL connection!") ha.isActive = false ha.checkResponsibility() @@ -89,7 +90,7 @@ func TestHA_checkResponsibility(t *testing.T) { assert.Equal(t, true, ha.isActive, "HA should be responsible, if another instance was inactive for a long time") _, err = ha.super.Dbw.SqlExec(mysqlTestObserver, "TRUNCATE TABLE icingadb_instance") - assert.NoError(t, err, "This test needs a working MySQL connection!") + require.NoError(t, err, "This test needs a working MySQL connection!") _, err = ha.super.Dbw.SqlExec(mysqlObservers.insertIntoIcingadbInstance, "INSERT INTO icingadb_instance(id, environment_id, heartbeat, responsible) VALUES (?, ?, ?, 'y')", diff --git a/ha/heartbeat_test.go b/ha/heartbeat_test.go index 8462d21f..55790453 100644 --- a/ha/heartbeat_test.go +++ b/ha/heartbeat_test.go @@ -4,6 +4,7 @@ import ( "encoding/json" "git.icinga.com/icingadb/icingadb-main/connection" "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" "os" "testing" "time" @@ -26,7 +27,7 @@ func TestIcingaHeartbeatListener(t *testing.T) { go func() { chErr := make(chan error) IcingaHeartbeatListener(rdb, chEnv, chErr) - assert.NoError(t, <-chErr, "redis connection error") + require.NoError(t, <-chErr, "redis connection error") }() time.Sleep(time.Second * 2)