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

Function TestUserCreateCmd

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

Source from the content-addressed store, hash-verified

28)
29
30func 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
52func TestUserRemoveCmd(t *testing.T) {
53 tmpDB := t.TempDir() + "/test.db"

Callers

nothing calls this directly

Calls 5

InitDBFunction · 0.92
MustExecFunction · 0.92
EqualFunction · 0.92
userCreateCmdFunction · 0.85
CloseMethod · 0.65

Tested by

no test coverage detected