CtrlK
CommunityDocumentationLog inGet started
Tessl Logo

tessl/golang-gorm-io--gorm

tessl install tessl/golang-gorm-io--gorm@1.31.0

Full-featured ORM library for Golang with associations, hooks, transactions, migrations, and developer-friendly chainable API

Agent Success

Agent success rate when using this tile

81%

Improvement

Agent success rate improvement when using this tile compared to baseline

1.13x

Baseline

Agent success rate without this tile

72%

task.mdevals/scenario-1/

Task Management System with Archive Functionality

Build a task management system that supports both archiving (soft delete) and permanent deletion (hard delete) of tasks.

Requirements

Implement a task management system with the following features:

  1. Task Model: Create a Task model with fields for ID, title, description, completed status, and timestamps (including soft delete support).

  2. Archive Task: Implement a function ArchiveTask(db, taskID) that archives (soft deletes) a task by its ID. Archived tasks should not appear in normal queries.

  3. Permanently Delete Task: Implement a function PermanentlyDeleteTask(db, taskID) that permanently removes a task from the database, bypassing any soft delete mechanism.

  4. List Active Tasks: Implement a function ListActiveTasks(db) that returns all non-archived tasks.

  5. List Archived Tasks: Implement a function ListArchivedTasks(db) that returns only the archived tasks.

  6. Bulk Archive Completed Tasks: Implement a function BulkArchiveCompletedTasks(db) that archives all tasks marked as completed.

Implementation Files

  • task.go: Define the Task model
  • operations.go: Implement all required functions
  • operations_test.go: Test file with test cases

Dependencies { .dependencies }

gorm.io/gorm { .dependency }

Provides ORM functionality for database operations.

gorm.io/driver/sqlite { .dependency }

Provides SQLite database driver for GORM.

Test Cases

Test 1: Archive and retrieve tasks @test

// File: operations_test.go
// Setup: Create 3 tasks
// Action: Archive task with ID 2
// Verify: ListActiveTasks returns 2 tasks (IDs 1 and 3)
// Verify: ListArchivedTasks returns 1 task (ID 2)

Test 2: Permanent deletion @test

// File: operations_test.go
// Setup: Create 2 tasks and archive task with ID 1
// Action: Call PermanentlyDeleteTask on task with ID 1
// Verify: ListArchivedTasks returns 0 tasks
// Verify: Database has only 1 task remaining (ID 2)

Test 3: Bulk archive completed tasks @test

// File: operations_test.go
// Setup: Create 5 tasks, mark 3 as completed
// Action: Call BulkArchiveCompletedTasks
// Verify: ListActiveTasks returns 2 tasks (uncompleted ones)
// Verify: ListArchivedTasks returns 3 tasks (completed ones)

Notes

  • Use appropriate database field types and model configuration for soft delete functionality
  • Ensure that normal queries automatically exclude archived tasks
  • Handle errors appropriately and return them to the caller
  • Use a SQLite in-memory database for testing

Version

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
golangpkg:golang/gorm.io/gorm@v1.31.1
tile.json