MCPcopy Index your code
hub / github.com/dnote/dnote / TestUserRemoveCmd

Function TestUserRemoveCmd

pkg/server/cmd/user_test.go:52–75  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

50}
51
52func TestUserRemoveCmd(t *testing.T) {
53 tmpDB := t.TempDir() + "/test.db"
54
55 // Create a user first
56 db := testutils.InitDB(tmpDB)
57 testutils.SetupUserData(db, "test@example.com", "password123")
58 sqlDB, _ := db.DB()
59 sqlDB.Close()
60
61 // Remove the user with mock stdin that responds "y"
62 mockStdin := strings.NewReader("y\n")
63 userRemoveCmd([]string{"--dbPath", tmpDB, "--email", "test@example.com"}, mockStdin)
64
65 // Verify user was removed
66 db2 := testutils.InitDB(tmpDB)
67 defer func() {
68 sqlDB2, _ := db2.DB()
69 sqlDB2.Close()
70 }()
71
72 var count int64
73 testutils.MustExec(t, db2.Model(&database.User{}).Count(&count), "counting users")
74 assert.Equal(t, count, int64(0), "should have 0 users")
75}
76
77func TestUserResetPasswordCmd(t *testing.T) {
78 tmpDB := t.TempDir() + "/test.db"

Callers

nothing calls this directly

Calls 6

InitDBFunction · 0.92
SetupUserDataFunction · 0.92
MustExecFunction · 0.92
EqualFunction · 0.92
userRemoveCmdFunction · 0.85
CloseMethod · 0.65

Tested by

no test coverage detected