(t *testing.T)
| 28 | ) |
| 29 | |
| 30 | func TestUserCreateCmd(t *testing.T) { |
| 31 | tmpDB := t.TempDir() + "/test.db" |
| 32 | |
| 33 | // Call the function directly |
| 34 | userCreateCmd([]string{"--dbPath", tmpDB, "--email", "test@example.com", "--password", "password123"}) |
| 35 | |
| 36 | // Verify user was created in database |
| 37 | db := testutils.InitDB(tmpDB) |
| 38 | defer func() { |
| 39 | sqlDB, _ := db.DB() |
| 40 | sqlDB.Close() |
| 41 | }() |
| 42 | |
| 43 | var count int64 |
| 44 | testutils.MustExec(t, db.Model(&database.User{}).Count(&count), "counting users") |
| 45 | assert.Equal(t, count, int64(1), "should have 1 user") |
| 46 | |
| 47 | var user database.User |
| 48 | testutils.MustExec(t, db.Where("email = ?", "test@example.com").First(&user), "finding user") |
| 49 | assert.Equal(t, user.Email.String, "test@example.com", "email mismatch") |
| 50 | } |
| 51 | |
| 52 | func TestUserRemoveCmd(t *testing.T) { |
| 53 | tmpDB := t.TempDir() + "/test.db" |
nothing calls this directly
no test coverage detected