CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/golang-gorm-io--gorm

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

Overall
score

81%

Overview
Eval results
Files

task.mdevals/scenario-1/

User Profile Manager

Build a user profile management system that models a one-to-one relationship between users and their profile information.

Requirements

You need to create two related data structures:

  1. User Model - represents a user with:

    • ID (auto-generated)
    • Username (string)
    • Email (string)
  2. Profile Model - represents profile information with:

    • ID (auto-generated)
    • Bio (string)
    • AvatarURL (string)
    • DateOfBirth (string)
    • Reference to the associated user

The relationship structure: each user has exactly one profile, and the profile belongs to that user.

Functionality

Initialize Database

Initialize an in-memory SQLite database and automatically migrate the models to create the necessary tables.

Create User with Profile

  • Create a user named "alice" with email "alice@example.com" @test
  • Create the user's profile with bio "Software Engineer", avatar "https://example.com/alice.jpg", and date of birth "1990-01-15" @test
  • Both user and profile should be saved to the database @test

Retrieve User with Profile

  • Query for a user by username @test
  • The query should automatically load the associated profile in a single operation @test
  • Verify all user and profile fields are correctly populated @test

Update Profile

  • Modify an existing profile's bio and avatar URL @test
  • Save the changes to the database @test
  • Verify updates persist when querying the user again @test

Dependencies { .dependencies }

gorm.io/gorm { .dependency }

Provides object-relational mapping for database operations.

gorm.io/driver/sqlite { .dependency }

SQLite database driver for GORM.

Deliverables

Implement the solution in main.go with all required data structures and database operations. Include tests in main_test.go that verify the test cases above.

Install with Tessl CLI

npx tessl i tessl/golang-gorm-io--gorm

tile.json