Skip to content

Commit

Permalink
Remove update and delete in entry
Browse files Browse the repository at this point in the history
  • Loading branch information
Vinayaks439 committed Dec 3, 2023
1 parent d0e1370 commit 7db4ca2
Show file tree
Hide file tree
Showing 4 changed files with 1 addition and 78 deletions.
13 changes: 1 addition & 12 deletions db/query/entries.sql
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,4 @@ INSERT INTO entries (
amount
) VALUES (
$1,$2
) RETURNING *;

-- name: UpdateEntry :one
UPDATE entries SET
account_id = $1,
amount = $2
WHERE id = $3
RETURNING *;

-- name: DeleteEntry :exec
DELETE FROM entries
WHERE id = $1;
) RETURNING *;
36 changes: 0 additions & 36 deletions db/sqlc/entries.sql.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 0 additions & 28 deletions db/sqlc/entries.sql_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,31 +47,3 @@ func TestListEntries(t *testing.T) {
require.NotZero(t, entry.CreatedAt)
}
}

func TestUpdateEntry(t *testing.T) {
args := UpdateEntryParams{
ID: 1,
Amount: 200,
}
entry, err := testQueries.UpdateEntry(context.Background(), args)
require.NoError(t, err)
require.NotEmpty(t, entry)
require.Equal(t, args.ID, entry.ID)
require.Equal(t, args.Amount, entry.Amount)
require.NotZero(t, entry.ID)
require.NotZero(t, entry.CreatedAt)

}
func TestDeleteEntry(t *testing.T) {
entry, err := testQueries.CreateEntries(context.Background(), CreateEntriesParams{
Amount: 100,
AccountID: int64(2),
})
getEntry, err := testQueries.GetEntry(context.Background(), entry.ID)
err = testQueries.DeleteEntry(context.Background(), 1)
require.NoError(t, err)
require.NotEmpty(t, getEntry)
require.Equal(t, entry.ID, getEntry.ID)
require.Equal(t, entry.AccountID, getEntry.AccountID)
require.Equal(t, entry.Amount, getEntry.Amount)
}
2 changes: 0 additions & 2 deletions db/sqlc/querier.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 7db4ca2

Please sign in to comment.