refactor(tests): Update all test files to use TestServerSetup pattern
This commit is contained in:
@@ -16,8 +16,7 @@ import (
|
||||
)
|
||||
|
||||
func TestDeviceRegistrationFlow(t *testing.T) {
|
||||
ts, _, _ := setupTestServer(t)
|
||||
defer ts.Close()
|
||||
setup := setupTestServer(t)
|
||||
|
||||
// Step 1: Initiate device registration
|
||||
regRequest := map[string]interface{}{
|
||||
@@ -198,11 +197,10 @@ func TestDeleteDevice(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestDeviceAuthentication(t *testing.T) {
|
||||
ts, db, _ := setupTestServer(t)
|
||||
defer ts.Close()
|
||||
setup := setupTestServer(t)
|
||||
|
||||
// Create a device directly in the database
|
||||
userID := getTestUserID(t, db)
|
||||
userID := getTestUserID(t, setup.DB)
|
||||
|
||||
deviceToken := fmt.Sprintf("dev_%s", uuid.New().String())
|
||||
_, err := db.CreateDevice(context.Background(), database.CreateDeviceParams{
|
||||
@@ -230,10 +228,9 @@ func TestDeviceAuthentication(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestListPendingRegistrations(t *testing.T) {
|
||||
ts, db, _ := setupTestServer(t)
|
||||
defer ts.Close()
|
||||
setup := setupTestServer(t)
|
||||
|
||||
token := loginTestUser(t, ts, db)
|
||||
token := loginTestUser(t, setup.Server, setup.DB)
|
||||
|
||||
req := httptest.NewRequest("GET", "/api/devices/pending", nil)
|
||||
req.Header.Set("Authorization", "Bearer "+token)
|
||||
@@ -251,10 +248,9 @@ func TestListPendingRegistrations(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestApproveDeviceRegistration(t *testing.T) {
|
||||
ts, db, _ := setupTestServer(t)
|
||||
defer ts.Close()
|
||||
setup := setupTestServer(t)
|
||||
|
||||
token := loginTestUser(t, ts, db)
|
||||
token := loginTestUser(t, setup.Server, setup.DB)
|
||||
|
||||
regRequest := map[string]interface{}{
|
||||
"device_name": "Test Device for Approval",
|
||||
@@ -290,10 +286,9 @@ func TestApproveDeviceRegistration(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestRejectDeviceRegistration(t *testing.T) {
|
||||
ts, db, _ := setupTestServer(t)
|
||||
defer ts.Close()
|
||||
setup := setupTestServer(t)
|
||||
|
||||
token := loginTestUser(t, ts, db)
|
||||
token := loginTestUser(t, setup.Server, setup.DB)
|
||||
|
||||
regRequest := map[string]interface{}{
|
||||
"device_name": "Test Device for Rejection",
|
||||
|
||||
Reference in New Issue
Block a user