79479875

Date: 2025-03-02 23:01:28
Score: 1
Natty:
Report link

I think I found the issue. I still investigating, but I notice that my function to initializa items wasn't define and ID for Items.

After this moditification on that struct:

func initializeItem(name string) *Item {
    return &Item{
        ItemID: valueobjects.NewItemID(uuid.New()),
        name:   name,
    }
}

and change my tests a little bit:

    t.Run("Retrieve unexisting item from vault", func(t *testing.T) {
        var vaultErr *VaultError

        vault.AddItem(item1, regPlayer)
        vaultSize := len(vault.Items)

        err := vault.RetriveItem(item.PickRandomItem(), regPlayer)
        assert.Error(t, vault.RetriveItem(item3, regPlayer))

        assert.ErrorAs(t, err, &vaultErr)
        assert.Contains(t, vaultErr.Error(), ErrItemNotFound.Error())
        assert.Equal(t, vaultSize, len(vault.Items))

    })

It starting to working.

I need to do more investigation to understand this. But for now, it working!

Reasons:
  • Blacklisted phrase (0.5): I need
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Self-answer (0.5):
  • Low reputation (1):
Posted by: Victor Felipe