mirror of
https://github.com/fleetdm/fleet
synced 2026-05-22 16:39:01 +00:00
* Migrate all mysql tests to the new form * Only dump sql if MYSQL_TEST is on * Removing parallel until we get rid of this code * Move TestMain to an actual _test file * A little experiment with tmpfs to speed up the db * Let's make sure the dump.sql file is also in ram
36 lines
718 B
Go
36 lines
718 B
Go
package mysql
|
|
|
|
import (
|
|
"testing"
|
|
"time"
|
|
|
|
"github.com/fleetdm/fleet/v4/server/fleet"
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestPasswordResetRequests(t *testing.T) {
|
|
db := CreateMySQLDS(t)
|
|
defer db.Close()
|
|
|
|
createTestUsers(t, db)
|
|
now := time.Now().UTC()
|
|
tomorrow := now.Add(time.Hour * 24)
|
|
var passwordResetTests = []struct {
|
|
userID uint
|
|
expires time.Time
|
|
token string
|
|
}{
|
|
{userID: 1, expires: tomorrow, token: "abcd"},
|
|
}
|
|
|
|
for _, tt := range passwordResetTests {
|
|
r := &fleet.PasswordResetRequest{
|
|
UserID: tt.userID,
|
|
ExpiresAt: tt.expires,
|
|
Token: tt.token,
|
|
}
|
|
req, err := db.NewPasswordResetRequest(r)
|
|
assert.Nil(t, err)
|
|
assert.Equal(t, tt.userID, req.UserID)
|
|
}
|
|
}
|