go-testfixtures / testfixtures

Ruby on Rails like test fixtures for Go. Write tests against a real database
https://pkg.go.dev/github.com/go-testfixtures/testfixtures/v3?tab=doc
MIT License
1.12k stars 80 forks source link

I am getting collumn not exist in loading fixtures #147

Closed tbhaxor closed 2 years ago

tbhaxor commented 2 years ago

I have created the fixtures using the following snippet


fixtures, err := testfixtures.New(
        testfixtures.Database(db),
        testfixtures.Dialect("postgres"),
        testfixtures.UseDropConstraint(),
        testfixtures.Directory("apps/api/ent/tests/data"),
        testfixtures.DangerousSkipTestDatabaseCheck(),
    )
    if err != nil {
        return err
    }
    return fixtures.Load()

When I run this code, I am getting

testfixtures: error inserting record: pq: column "currentSupply" of relation "collections" does not exist, on file: collections.yaml

Also in the collections.yaml file the field exists

- created: "2008-05-22T16:12:37.808839923Z"
  currentSupply: 1
  description: Voluptas beatae eum sit nesciunt laboriosam voluptates distinctio aspernatur
    voluptas.
  id: 5902903159430590834
  image: https://picsum.photos/250/250
  longName: Cujo-EhiiTSPeXR3
  maxSupply: 8
  modified: "2008-05-22T16:12:37.808839923Z"
  name: Cujo
  orgId: 8021333953255315354

Note I have executed migraions before running this code

andreynering commented 2 years ago

Hi @tbhaxor,

This error is from PostgreSQL. It is telling you that the column collections.currentSupply does not exist in your database.