DRY up storage diff repo tests
This commit is contained in:
parent
5746de7c97
commit
56ca45509f
@ -5,6 +5,7 @@ import (
|
||||
. "github.com/onsi/gomega"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/datastore/postgres"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/transformers/storage_diffs/maker/cat"
|
||||
. "github.com/vulcanize/vulcanizedb/pkg/transformers/storage_diffs/maker/test_helpers"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/transformers/storage_diffs/shared"
|
||||
"github.com/vulcanize/vulcanizedb/test_config"
|
||||
)
|
||||
@ -40,9 +41,7 @@ var _ = Describe("Cat storage repository", func() {
|
||||
|
||||
err = db.Get(&result, `SELECT block_number, block_hash, nflip AS value FROM maker.cat_nflip`)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
Expect(result.BlockNumber).To(Equal(fakeBlockNumber))
|
||||
Expect(result.BlockHash).To(Equal(fakeBlockHash))
|
||||
Expect(result.Value).To(Equal(fakeUint256))
|
||||
AssertVariable(result, fakeBlockNumber, fakeBlockHash, fakeUint256)
|
||||
})
|
||||
})
|
||||
|
||||
@ -55,9 +54,7 @@ var _ = Describe("Cat storage repository", func() {
|
||||
|
||||
err = db.Get(&result, `SELECT block_number, block_hash, live AS value FROM maker.cat_live`)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
Expect(result.BlockNumber).To(Equal(fakeBlockNumber))
|
||||
Expect(result.BlockHash).To(Equal(fakeBlockHash))
|
||||
Expect(result.Value).To(Equal(fakeUint256))
|
||||
AssertVariable(result, fakeBlockNumber, fakeBlockHash, fakeUint256)
|
||||
})
|
||||
})
|
||||
|
||||
@ -70,9 +67,7 @@ var _ = Describe("Cat storage repository", func() {
|
||||
|
||||
err = db.Get(&result, `SELECT block_number, block_hash, vat AS value FROM maker.cat_vat`)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
Expect(result.BlockNumber).To(Equal(fakeBlockNumber))
|
||||
Expect(result.BlockHash).To(Equal(fakeBlockHash))
|
||||
Expect(result.Value).To(Equal(fakeAddress))
|
||||
AssertVariable(result, fakeBlockNumber, fakeBlockHash, fakeAddress)
|
||||
})
|
||||
})
|
||||
|
||||
@ -85,9 +80,7 @@ var _ = Describe("Cat storage repository", func() {
|
||||
|
||||
err = db.Get(&result, `SELECT block_number, block_hash, pit AS value FROM maker.cat_pit`)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
Expect(result.BlockNumber).To(Equal(fakeBlockNumber))
|
||||
Expect(result.BlockHash).To(Equal(fakeBlockHash))
|
||||
Expect(result.Value).To(Equal(fakeAddress))
|
||||
AssertVariable(result, fakeBlockNumber, fakeBlockHash, fakeAddress)
|
||||
})
|
||||
})
|
||||
|
||||
@ -100,9 +93,7 @@ var _ = Describe("Cat storage repository", func() {
|
||||
|
||||
err = db.Get(&result, `SELECT block_number, block_hash, vow AS value FROM maker.cat_vow`)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
Expect(result.BlockNumber).To(Equal(fakeBlockNumber))
|
||||
Expect(result.BlockHash).To(Equal(fakeBlockHash))
|
||||
Expect(result.Value).To(Equal(fakeAddress))
|
||||
AssertVariable(result, fakeBlockNumber, fakeBlockHash, fakeAddress)
|
||||
})
|
||||
})
|
||||
})
|
||||
@ -119,10 +110,7 @@ var _ = Describe("Cat storage repository", func() {
|
||||
|
||||
err = db.Get(&result, `SELECT block_number, block_hash, ilk AS key, flip AS value FROM maker.cat_ilk_flip`)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
Expect(result.BlockNumber).To(Equal(fakeBlockNumber))
|
||||
Expect(result.BlockHash).To(Equal(fakeBlockHash))
|
||||
Expect(result.Key).To(Equal(fakeIlk))
|
||||
Expect(result.Value).To(Equal(fakeAddress))
|
||||
AssertMapping(result, fakeBlockNumber, fakeBlockHash, fakeIlk, fakeAddress)
|
||||
})
|
||||
|
||||
It("returns an error if metadata missing ilk", func() {
|
||||
@ -142,10 +130,7 @@ var _ = Describe("Cat storage repository", func() {
|
||||
|
||||
err = db.Get(&result, `SELECT block_number, block_hash, ilk AS key, chop AS value FROM maker.cat_ilk_chop`)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
Expect(result.BlockNumber).To(Equal(fakeBlockNumber))
|
||||
Expect(result.BlockHash).To(Equal(fakeBlockHash))
|
||||
Expect(result.Key).To(Equal(fakeIlk))
|
||||
Expect(result.Value).To(Equal(fakeUint256))
|
||||
AssertMapping(result, fakeBlockNumber, fakeBlockHash, fakeIlk, fakeUint256)
|
||||
})
|
||||
|
||||
It("returns an error if metadata missing ilk", func() {
|
||||
@ -165,10 +150,7 @@ var _ = Describe("Cat storage repository", func() {
|
||||
|
||||
err = db.Get(&result, `SELECT block_number, block_hash, ilk AS key, lump AS value FROM maker.cat_ilk_lump`)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
Expect(result.BlockNumber).To(Equal(fakeBlockNumber))
|
||||
Expect(result.BlockHash).To(Equal(fakeBlockHash))
|
||||
Expect(result.Key).To(Equal(fakeIlk))
|
||||
Expect(result.Value).To(Equal(fakeUint256))
|
||||
AssertMapping(result, fakeBlockNumber, fakeBlockHash, fakeIlk, fakeUint256)
|
||||
})
|
||||
|
||||
It("returns an error if metadata missing ilk", func() {
|
||||
@ -192,10 +174,7 @@ var _ = Describe("Cat storage repository", func() {
|
||||
|
||||
err = db.Get(&result, `SELECT block_number, block_hash, nflip AS key, ilk AS value FROM maker.cat_flip_ilk`)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
Expect(result.BlockNumber).To(Equal(fakeBlockNumber))
|
||||
Expect(result.BlockHash).To(Equal(fakeBlockHash))
|
||||
Expect(result.Key).To(Equal(fakeUint256))
|
||||
Expect(result.Value).To(Equal(fakeBytes32))
|
||||
AssertMapping(result, fakeBlockNumber, fakeBlockHash, fakeUint256, fakeBytes32)
|
||||
})
|
||||
|
||||
It("returns an error if metadata missing flip", func() {
|
||||
@ -215,10 +194,7 @@ var _ = Describe("Cat storage repository", func() {
|
||||
|
||||
err = db.Get(&result, `SELECT block_number, block_hash, nflip AS key, urn AS value FROM maker.cat_flip_urn`)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
Expect(result.BlockNumber).To(Equal(fakeBlockNumber))
|
||||
Expect(result.BlockHash).To(Equal(fakeBlockHash))
|
||||
Expect(result.Key).To(Equal(fakeUint256))
|
||||
Expect(result.Value).To(Equal(fakeBytes32))
|
||||
AssertMapping(result, fakeBlockNumber, fakeBlockHash, fakeUint256, fakeBytes32)
|
||||
})
|
||||
|
||||
It("returns an error if metadata missing flip", func() {
|
||||
@ -238,10 +214,7 @@ var _ = Describe("Cat storage repository", func() {
|
||||
|
||||
err = db.Get(&result, `SELECT block_number, block_hash, nflip AS key, ink AS value FROM maker.cat_flip_ink`)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
Expect(result.BlockNumber).To(Equal(fakeBlockNumber))
|
||||
Expect(result.BlockHash).To(Equal(fakeBlockHash))
|
||||
Expect(result.Key).To(Equal(fakeUint256))
|
||||
Expect(result.Value).To(Equal(fakeUint256))
|
||||
AssertMapping(result, fakeBlockNumber, fakeBlockHash, fakeUint256, fakeUint256)
|
||||
})
|
||||
|
||||
It("returns an error if metadata missing flip", func() {
|
||||
@ -261,10 +234,7 @@ var _ = Describe("Cat storage repository", func() {
|
||||
|
||||
err = db.Get(&result, `SELECT block_number, block_hash, nflip AS key, tab AS value FROM maker.cat_flip_tab`)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
Expect(result.BlockNumber).To(Equal(fakeBlockNumber))
|
||||
Expect(result.BlockHash).To(Equal(fakeBlockHash))
|
||||
Expect(result.Key).To(Equal(fakeUint256))
|
||||
Expect(result.Value).To(Equal(fakeUint256))
|
||||
AssertMapping(result, fakeBlockNumber, fakeBlockHash, fakeUint256, fakeUint256)
|
||||
})
|
||||
|
||||
It("returns an error if metadata missing flip", func() {
|
||||
@ -276,19 +246,3 @@ var _ = Describe("Cat storage repository", func() {
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
type BlockMetadata struct {
|
||||
BlockNumber int `db:"block_number"`
|
||||
BlockHash string `db:"block_hash"`
|
||||
}
|
||||
|
||||
type MappingRes struct {
|
||||
BlockMetadata
|
||||
Key string
|
||||
Value string
|
||||
}
|
||||
|
||||
type VariableRes struct {
|
||||
BlockMetadata
|
||||
Value string
|
||||
}
|
||||
|
@ -21,6 +21,7 @@ import (
|
||||
. "github.com/onsi/gomega"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/datastore/postgres"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/transformers/storage_diffs/maker/pit"
|
||||
. "github.com/vulcanize/vulcanizedb/pkg/transformers/storage_diffs/maker/test_helpers"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/transformers/storage_diffs/shared"
|
||||
"github.com/vulcanize/vulcanizedb/test_config"
|
||||
)
|
||||
@ -54,18 +55,11 @@ var _ = Describe("Pit storage repository", func() {
|
||||
err = repo.Create(blockNumber, blockHash, ilkLineMetadata, expectedLine)
|
||||
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
type IlkLine struct {
|
||||
BlockMetadata
|
||||
Ilk string
|
||||
Line string
|
||||
}
|
||||
var result IlkLine
|
||||
err = db.Get(&result, `SELECT block_number, block_hash, ilk, line FROM maker.pit_ilk_line`)
|
||||
|
||||
var result MappingRes
|
||||
err = db.Get(&result, `SELECT block_number, block_hash, ilk AS key, line AS value FROM maker.pit_ilk_line`)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
Expect(result.BlockNumber).To(Equal(blockNumber))
|
||||
Expect(result.BlockHash).To(Equal(blockHash))
|
||||
Expect(result.Ilk).To(Equal(expectedIlk))
|
||||
Expect(result.Line).To(Equal(expectedLine))
|
||||
AssertMapping(result, blockNumber, blockHash, expectedIlk, expectedLine)
|
||||
})
|
||||
|
||||
It("persists an ilk spot", func() {
|
||||
@ -79,18 +73,11 @@ var _ = Describe("Pit storage repository", func() {
|
||||
err = repo.Create(blockNumber, blockHash, ilkSpotMetadata, expectedSpot)
|
||||
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
type IlkSpot struct {
|
||||
BlockMetadata
|
||||
Ilk string
|
||||
Spot string
|
||||
}
|
||||
var result IlkSpot
|
||||
err = db.Get(&result, `SELECT block_number, block_hash, ilk, spot FROM maker.pit_ilk_spot`)
|
||||
|
||||
var result MappingRes
|
||||
err = db.Get(&result, `SELECT block_number, block_hash, ilk AS key, spot AS value FROM maker.pit_ilk_spot`)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
Expect(result.BlockNumber).To(Equal(blockNumber))
|
||||
Expect(result.BlockHash).To(Equal(blockHash))
|
||||
Expect(result.Ilk).To(Equal(expectedIlk))
|
||||
Expect(result.Spot).To(Equal(expectedSpot))
|
||||
AssertMapping(result, blockNumber, blockHash, expectedIlk, expectedSpot)
|
||||
})
|
||||
|
||||
It("persists a pit drip", func() {
|
||||
@ -99,16 +86,11 @@ var _ = Describe("Pit storage repository", func() {
|
||||
err = repo.Create(blockNumber, blockHash, pit.DripMetadata, expectedDrip)
|
||||
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
type PitDrip struct {
|
||||
BlockMetadata
|
||||
Drip string
|
||||
}
|
||||
var result PitDrip
|
||||
err = db.Get(&result, `SELECT block_number, block_hash, drip FROM maker.pit_drip`)
|
||||
|
||||
var result VariableRes
|
||||
err = db.Get(&result, `SELECT block_number, block_hash, drip AS value FROM maker.pit_drip`)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
Expect(result.BlockNumber).To(Equal(blockNumber))
|
||||
Expect(result.BlockHash).To(Equal(blockHash))
|
||||
Expect(result.Drip).To(Equal(expectedDrip))
|
||||
AssertVariable(result, blockNumber, blockHash, expectedDrip)
|
||||
})
|
||||
|
||||
It("persists a pit line", func() {
|
||||
@ -117,16 +99,11 @@ var _ = Describe("Pit storage repository", func() {
|
||||
err = repo.Create(blockNumber, blockHash, pit.LineMetadata, expectedLine)
|
||||
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
type PitLine struct {
|
||||
BlockMetadata
|
||||
Line string
|
||||
}
|
||||
var result PitLine
|
||||
err = db.Get(&result, `SELECT block_number, block_hash, line FROM maker.pit_line`)
|
||||
|
||||
var result VariableRes
|
||||
err = db.Get(&result, `SELECT block_number, block_hash, line AS value FROM maker.pit_line`)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
Expect(result.BlockNumber).To(Equal(blockNumber))
|
||||
Expect(result.BlockHash).To(Equal(blockHash))
|
||||
Expect(result.Line).To(Equal(expectedLine))
|
||||
AssertVariable(result, blockNumber, blockHash, expectedLine)
|
||||
})
|
||||
|
||||
It("persists a pit live", func() {
|
||||
@ -135,16 +112,11 @@ var _ = Describe("Pit storage repository", func() {
|
||||
err = repo.Create(blockNumber, blockHash, pit.LiveMetadata, expectedLive)
|
||||
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
type PitLive struct {
|
||||
BlockMetadata
|
||||
Live string
|
||||
}
|
||||
var result PitLive
|
||||
err = db.Get(&result, `SELECT block_number, block_hash, live FROM maker.pit_live`)
|
||||
|
||||
var result VariableRes
|
||||
err = db.Get(&result, `SELECT block_number, block_hash, live AS value FROM maker.pit_live`)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
Expect(result.BlockNumber).To(Equal(blockNumber))
|
||||
Expect(result.BlockHash).To(Equal(blockHash))
|
||||
Expect(result.Live).To(Equal(expectedLive))
|
||||
AssertVariable(result, blockNumber, blockHash, expectedLive)
|
||||
})
|
||||
|
||||
It("persists a pit vat", func() {
|
||||
@ -153,20 +125,10 @@ var _ = Describe("Pit storage repository", func() {
|
||||
err = repo.Create(blockNumber, blockHash, pit.VatMetadata, expectedVat)
|
||||
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
type PitVat struct {
|
||||
BlockMetadata
|
||||
Vat string
|
||||
}
|
||||
var result PitVat
|
||||
err = db.Get(&result, `SELECT block_number, block_hash, vat FROM maker.pit_vat`)
|
||||
|
||||
var result VariableRes
|
||||
err = db.Get(&result, `SELECT block_number, block_hash, vat AS value FROM maker.pit_vat`)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
Expect(result.BlockNumber).To(Equal(blockNumber))
|
||||
Expect(result.BlockHash).To(Equal(blockHash))
|
||||
Expect(result.Vat).To(Equal(expectedVat))
|
||||
AssertVariable(result, blockNumber, blockHash, expectedVat)
|
||||
})
|
||||
})
|
||||
|
||||
type BlockMetadata struct {
|
||||
BlockNumber int `db:"block_number"`
|
||||
BlockHash string `db:"block_hash"`
|
||||
}
|
||||
|
@ -0,0 +1,49 @@
|
||||
package test_helpers
|
||||
|
||||
import (
|
||||
. "github.com/onsi/gomega"
|
||||
)
|
||||
|
||||
type BlockMetadata struct {
|
||||
BlockNumber int `db:"block_number"`
|
||||
BlockHash string `db:"block_hash"`
|
||||
}
|
||||
|
||||
type VariableRes struct {
|
||||
BlockMetadata
|
||||
Value string
|
||||
}
|
||||
|
||||
type MappingRes struct {
|
||||
BlockMetadata
|
||||
Key string
|
||||
Value string
|
||||
}
|
||||
|
||||
type DoubleMappingRes struct {
|
||||
BlockMetadata
|
||||
KeyOne string `db:"key_one"`
|
||||
KeyTwo string `db:"key_two"`
|
||||
Value string
|
||||
}
|
||||
|
||||
func AssertVariable(res VariableRes, blockNumber int, blockHash, value string) {
|
||||
Expect(res.BlockNumber).To(Equal(blockNumber))
|
||||
Expect(res.BlockHash).To(Equal(blockHash))
|
||||
Expect(res.Value).To(Equal(value))
|
||||
}
|
||||
|
||||
func AssertMapping(res MappingRes, blockNumber int, blockHash, key, value string) {
|
||||
Expect(res.BlockNumber).To(Equal(blockNumber))
|
||||
Expect(res.BlockHash).To(Equal(blockHash))
|
||||
Expect(res.Key).To(Equal(key))
|
||||
Expect(res.Value).To(Equal(value))
|
||||
}
|
||||
|
||||
func AssertDoubleMapping(res DoubleMappingRes, blockNumber int, blockHash, keyOne, keyTwo, value string) {
|
||||
Expect(res.BlockNumber).To(Equal(blockNumber))
|
||||
Expect(res.BlockHash).To(Equal(blockHash))
|
||||
Expect(res.KeyOne).To(Equal(keyOne))
|
||||
Expect(res.KeyTwo).To(Equal(keyTwo))
|
||||
Expect(res.Value).To(Equal(value))
|
||||
}
|
@ -4,6 +4,7 @@ import (
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/gomega"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/datastore/postgres"
|
||||
. "github.com/vulcanize/vulcanizedb/pkg/transformers/storage_diffs/maker/test_helpers"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/transformers/storage_diffs/maker/vat"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/transformers/storage_diffs/shared"
|
||||
"github.com/vulcanize/vulcanizedb/test_config"
|
||||
@ -38,18 +39,11 @@ var _ = Describe("Vat storage repository", func() {
|
||||
err := repo.Create(fakeBlockNumber, fakeBlockHash, daiMetadata, fakeUint256)
|
||||
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
type Dai struct {
|
||||
BlockMetadata
|
||||
Guy string
|
||||
Dai string
|
||||
}
|
||||
var result Dai
|
||||
err = db.Get(&result, `SELECT block_number, block_hash, guy, dai FROM maker.vat_dai`)
|
||||
|
||||
var result MappingRes
|
||||
err = db.Get(&result, `SELECT block_number, block_hash, guy AS key, dai AS value FROM maker.vat_dai`)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
Expect(result.BlockNumber).To(Equal(fakeBlockNumber))
|
||||
Expect(result.BlockHash).To(Equal(fakeBlockHash))
|
||||
Expect(result.Guy).To(Equal(fakeGuy))
|
||||
Expect(result.Dai).To(Equal(fakeUint256))
|
||||
AssertMapping(result, fakeBlockNumber, fakeBlockHash, fakeGuy, fakeUint256)
|
||||
})
|
||||
|
||||
It("returns error if metadata missing guy", func() {
|
||||
@ -77,20 +71,11 @@ var _ = Describe("Vat storage repository", func() {
|
||||
err := repo.Create(fakeBlockNumber, fakeBlockHash, gemMetadata, fakeUint256)
|
||||
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
type Gem struct {
|
||||
BlockMetadata
|
||||
Ilk string
|
||||
Guy string
|
||||
Gem string
|
||||
}
|
||||
var result Gem
|
||||
err = db.Get(&result, `SELECT block_number, block_hash, ilk, guy, gem FROM maker.vat_gem`)
|
||||
|
||||
var result DoubleMappingRes
|
||||
err = db.Get(&result, `SELECT block_number, block_hash, ilk AS key_one, guy AS key_two, gem AS value FROM maker.vat_gem`)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
Expect(result.BlockNumber).To(Equal(fakeBlockNumber))
|
||||
Expect(result.BlockHash).To(Equal(fakeBlockHash))
|
||||
Expect(result.Ilk).To(Equal(fakeIlk))
|
||||
Expect(result.Guy).To(Equal(fakeGuy))
|
||||
Expect(result.Gem).To(Equal(fakeUint256))
|
||||
AssertDoubleMapping(result, fakeBlockNumber, fakeBlockHash, fakeIlk, fakeGuy, fakeUint256)
|
||||
})
|
||||
|
||||
It("returns error if metadata missing ilk", func() {
|
||||
@ -131,18 +116,11 @@ var _ = Describe("Vat storage repository", func() {
|
||||
err := repo.Create(fakeBlockNumber, fakeBlockHash, ilkArtMetadata, fakeUint256)
|
||||
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
type IlkArt struct {
|
||||
BlockMetadata
|
||||
Ilk string
|
||||
Art string
|
||||
}
|
||||
var result IlkArt
|
||||
err = db.Get(&result, `SELECT block_number, block_hash, ilk, art FROM maker.vat_ilk_art`)
|
||||
|
||||
var result MappingRes
|
||||
err = db.Get(&result, `SELECT block_number, block_hash, ilk AS key, art AS value FROM maker.vat_ilk_art`)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
Expect(result.BlockNumber).To(Equal(fakeBlockNumber))
|
||||
Expect(result.BlockHash).To(Equal(fakeBlockHash))
|
||||
Expect(result.Ilk).To(Equal(fakeIlk))
|
||||
Expect(result.Art).To(Equal(fakeUint256))
|
||||
AssertMapping(result, fakeBlockNumber, fakeBlockHash, fakeIlk, fakeUint256)
|
||||
})
|
||||
|
||||
It("returns error if metadata missing ilk", func() {
|
||||
@ -170,18 +148,11 @@ var _ = Describe("Vat storage repository", func() {
|
||||
err := repo.Create(fakeBlockNumber, fakeBlockHash, ilkInkMetadata, fakeUint256)
|
||||
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
type IlkInk struct {
|
||||
BlockMetadata
|
||||
Ilk string
|
||||
Ink string
|
||||
}
|
||||
var result IlkInk
|
||||
err = db.Get(&result, `SELECT block_number, block_hash, ilk, ink FROM maker.vat_ilk_ink`)
|
||||
|
||||
var result MappingRes
|
||||
err = db.Get(&result, `SELECT block_number, block_hash, ilk AS key, ink AS value FROM maker.vat_ilk_ink`)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
Expect(result.BlockNumber).To(Equal(fakeBlockNumber))
|
||||
Expect(result.BlockHash).To(Equal(fakeBlockHash))
|
||||
Expect(result.Ilk).To(Equal(fakeIlk))
|
||||
Expect(result.Ink).To(Equal(fakeUint256))
|
||||
AssertMapping(result, fakeBlockNumber, fakeBlockHash, fakeIlk, fakeUint256)
|
||||
})
|
||||
|
||||
It("returns error if metadata missing ilk", func() {
|
||||
@ -209,18 +180,11 @@ var _ = Describe("Vat storage repository", func() {
|
||||
err := repo.Create(fakeBlockNumber, fakeBlockHash, ilkRateMetadata, fakeUint256)
|
||||
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
type IlkRate struct {
|
||||
BlockMetadata
|
||||
Ilk string
|
||||
Rate string
|
||||
}
|
||||
var result IlkRate
|
||||
err = db.Get(&result, `SELECT block_number, block_hash, ilk, rate FROM maker.vat_ilk_rate`)
|
||||
|
||||
var result MappingRes
|
||||
err = db.Get(&result, `SELECT block_number, block_hash, ilk AS key, rate AS value FROM maker.vat_ilk_rate`)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
Expect(result.BlockNumber).To(Equal(fakeBlockNumber))
|
||||
Expect(result.BlockHash).To(Equal(fakeBlockHash))
|
||||
Expect(result.Ilk).To(Equal(fakeIlk))
|
||||
Expect(result.Rate).To(Equal(fakeUint256))
|
||||
AssertMapping(result, fakeBlockNumber, fakeBlockHash, fakeIlk, fakeUint256)
|
||||
})
|
||||
|
||||
It("returns error if metadata missing ilk", func() {
|
||||
@ -248,18 +212,11 @@ var _ = Describe("Vat storage repository", func() {
|
||||
err := repo.Create(fakeBlockNumber, fakeBlockHash, ilkTakeMetadata, fakeUint256)
|
||||
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
type IlkTake struct {
|
||||
BlockMetadata
|
||||
Ilk string
|
||||
Take string
|
||||
}
|
||||
var result IlkTake
|
||||
err = db.Get(&result, `SELECT block_number, block_hash, ilk, take FROM maker.vat_ilk_take`)
|
||||
|
||||
var result MappingRes
|
||||
err = db.Get(&result, `SELECT block_number, block_hash, ilk AS key, take AS value FROM maker.vat_ilk_take`)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
Expect(result.BlockNumber).To(Equal(fakeBlockNumber))
|
||||
Expect(result.BlockHash).To(Equal(fakeBlockHash))
|
||||
Expect(result.Ilk).To(Equal(fakeIlk))
|
||||
Expect(result.Take).To(Equal(fakeUint256))
|
||||
AssertMapping(result, fakeBlockNumber, fakeBlockHash, fakeIlk, fakeUint256)
|
||||
})
|
||||
|
||||
It("returns error if metadata missing ilk", func() {
|
||||
@ -287,18 +244,11 @@ var _ = Describe("Vat storage repository", func() {
|
||||
err := repo.Create(fakeBlockNumber, fakeBlockHash, sinMetadata, fakeUint256)
|
||||
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
type Sin struct {
|
||||
BlockMetadata
|
||||
Guy string
|
||||
Sin string
|
||||
}
|
||||
var result Sin
|
||||
err = db.Get(&result, `SELECT block_number, block_hash, guy, sin FROM maker.vat_sin`)
|
||||
|
||||
var result MappingRes
|
||||
err = db.Get(&result, `SELECT block_number, block_hash, guy AS key, sin AS value FROM maker.vat_sin`)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
Expect(result.BlockNumber).To(Equal(fakeBlockNumber))
|
||||
Expect(result.BlockHash).To(Equal(fakeBlockHash))
|
||||
Expect(result.Guy).To(Equal(fakeGuy))
|
||||
Expect(result.Sin).To(Equal(fakeUint256))
|
||||
AssertMapping(result, fakeBlockNumber, fakeBlockHash, fakeGuy, fakeUint256)
|
||||
})
|
||||
|
||||
It("returns error if metadata missing guy", func() {
|
||||
@ -326,20 +276,11 @@ var _ = Describe("Vat storage repository", func() {
|
||||
err := repo.Create(fakeBlockNumber, fakeBlockHash, urnArtMetadata, fakeUint256)
|
||||
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
type UrnArt struct {
|
||||
BlockMetadata
|
||||
Ilk string
|
||||
Urn string
|
||||
Art string
|
||||
}
|
||||
var result UrnArt
|
||||
err = db.Get(&result, `SELECT block_number, block_hash, ilk, urn, art FROM maker.vat_urn_art`)
|
||||
|
||||
var result DoubleMappingRes
|
||||
err = db.Get(&result, `SELECT block_number, block_hash, ilk AS key_one, urn AS key_two, art AS value FROM maker.vat_urn_art`)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
Expect(result.BlockNumber).To(Equal(fakeBlockNumber))
|
||||
Expect(result.BlockHash).To(Equal(fakeBlockHash))
|
||||
Expect(result.Ilk).To(Equal(fakeIlk))
|
||||
Expect(result.Urn).To(Equal(fakeGuy))
|
||||
Expect(result.Art).To(Equal(fakeUint256))
|
||||
AssertDoubleMapping(result, fakeBlockNumber, fakeBlockHash, fakeIlk, fakeGuy, fakeUint256)
|
||||
})
|
||||
|
||||
It("returns error if metadata missing ilk", func() {
|
||||
@ -380,20 +321,11 @@ var _ = Describe("Vat storage repository", func() {
|
||||
err := repo.Create(fakeBlockNumber, fakeBlockHash, urnInkMetadata, fakeUint256)
|
||||
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
type UrnInk struct {
|
||||
BlockMetadata
|
||||
Ilk string
|
||||
Urn string
|
||||
Ink string
|
||||
}
|
||||
var result UrnInk
|
||||
err = db.Get(&result, `SELECT block_number, block_hash, ilk, urn, ink FROM maker.vat_urn_ink`)
|
||||
|
||||
var result DoubleMappingRes
|
||||
err = db.Get(&result, `SELECT block_number, block_hash, ilk AS key_one, urn AS key_two, ink AS value FROM maker.vat_urn_ink`)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
Expect(result.BlockNumber).To(Equal(fakeBlockNumber))
|
||||
Expect(result.BlockHash).To(Equal(fakeBlockHash))
|
||||
Expect(result.Ilk).To(Equal(fakeIlk))
|
||||
Expect(result.Urn).To(Equal(fakeGuy))
|
||||
Expect(result.Ink).To(Equal(fakeUint256))
|
||||
AssertDoubleMapping(result, fakeBlockNumber, fakeBlockHash, fakeIlk, fakeGuy, fakeUint256)
|
||||
})
|
||||
|
||||
It("returns error if metadata missing ilk", func() {
|
||||
@ -433,16 +365,11 @@ var _ = Describe("Vat storage repository", func() {
|
||||
err := repo.Create(fakeBlockNumber, fakeBlockHash, debtMetadata, fakeUint256)
|
||||
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
type Debt struct {
|
||||
BlockMetadata
|
||||
Debt string
|
||||
}
|
||||
var result Debt
|
||||
err = db.Get(&result, `SELECT block_number, block_hash, debt FROM maker.vat_debt`)
|
||||
|
||||
var result VariableRes
|
||||
err = db.Get(&result, `SELECT block_number, block_hash, debt AS value FROM maker.vat_debt`)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
Expect(result.BlockNumber).To(Equal(fakeBlockNumber))
|
||||
Expect(result.BlockHash).To(Equal(fakeBlockHash))
|
||||
Expect(result.Debt).To(Equal(fakeUint256))
|
||||
AssertVariable(result, fakeBlockNumber, fakeBlockHash, fakeUint256)
|
||||
})
|
||||
|
||||
It("persists vat vice", func() {
|
||||
@ -455,20 +382,10 @@ var _ = Describe("Vat storage repository", func() {
|
||||
err := repo.Create(fakeBlockNumber, fakeBlockHash, viceMetadata, fakeUint256)
|
||||
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
type Vice struct {
|
||||
BlockMetadata
|
||||
Vice string
|
||||
}
|
||||
var result Vice
|
||||
err = db.Get(&result, `SELECT block_number, block_hash, vice FROM maker.vat_vice`)
|
||||
|
||||
var result VariableRes
|
||||
err = db.Get(&result, `SELECT block_number, block_hash, vice AS value FROM maker.vat_vice`)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
Expect(result.BlockNumber).To(Equal(fakeBlockNumber))
|
||||
Expect(result.BlockHash).To(Equal(fakeBlockHash))
|
||||
Expect(result.Vice).To(Equal(fakeUint256))
|
||||
AssertVariable(result, fakeBlockNumber, fakeBlockHash, fakeUint256)
|
||||
})
|
||||
})
|
||||
|
||||
type BlockMetadata struct {
|
||||
BlockNumber int `db:"block_number"`
|
||||
BlockHash string `db:"block_hash"`
|
||||
}
|
||||
|
@ -19,6 +19,7 @@ package vow_test
|
||||
import (
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/gomega"
|
||||
. "github.com/vulcanize/vulcanizedb/pkg/transformers/storage_diffs/maker/test_helpers"
|
||||
|
||||
"github.com/vulcanize/vulcanizedb/pkg/datastore/postgres"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/transformers/storage_diffs/maker/vow"
|
||||
@ -49,16 +50,11 @@ var _ = Describe("Vow storage repository test", func() {
|
||||
err = repo.Create(blockNumber, blockHash, vow.VatMetadata, expectedVat)
|
||||
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
type VowVat struct {
|
||||
BlockMetadata
|
||||
Vat string
|
||||
}
|
||||
var result VowVat
|
||||
err = db.Get(&result, `SELECT block_number, block_hash, vat from maker.vow_vat`)
|
||||
|
||||
var result VariableRes
|
||||
err = db.Get(&result, `SELECT block_number, block_hash, vat AS value from maker.vow_vat`)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
Expect(result.BlockNumber).To(Equal(blockNumber))
|
||||
Expect(result.BlockHash).To(Equal(blockHash))
|
||||
Expect(result.Vat).To(Equal(expectedVat))
|
||||
AssertVariable(result, blockNumber, blockHash, expectedVat)
|
||||
})
|
||||
|
||||
It("persists a vow cow", func() {
|
||||
@ -67,16 +63,11 @@ var _ = Describe("Vow storage repository test", func() {
|
||||
err = repo.Create(blockNumber, blockHash, vow.CowMetadata, expectedCow)
|
||||
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
type VowCow struct {
|
||||
BlockMetadata
|
||||
Cow string
|
||||
}
|
||||
var result VowCow
|
||||
err = db.Get(&result, `SELECT block_number, block_hash, cow from maker.vow_cow`)
|
||||
|
||||
var result VariableRes
|
||||
err = db.Get(&result, `SELECT block_number, block_hash, cow AS value from maker.vow_cow`)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
Expect(result.BlockNumber).To(Equal(blockNumber))
|
||||
Expect(result.BlockHash).To(Equal(blockHash))
|
||||
Expect(result.Cow).To(Equal(expectedCow))
|
||||
AssertVariable(result, blockNumber, blockHash, expectedCow)
|
||||
})
|
||||
|
||||
It("persists a vow row", func() {
|
||||
@ -85,16 +76,11 @@ var _ = Describe("Vow storage repository test", func() {
|
||||
err = repo.Create(blockNumber, blockHash, vow.RowMetadata, expectedRow)
|
||||
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
type VowRow struct {
|
||||
BlockMetadata
|
||||
Row string
|
||||
}
|
||||
var result VowRow
|
||||
err = db.Get(&result, `SELECT block_number, block_hash, row from maker.vow_row`)
|
||||
|
||||
var result VariableRes
|
||||
err = db.Get(&result, `SELECT block_number, block_hash, row AS value from maker.vow_row`)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
Expect(result.BlockNumber).To(Equal(blockNumber))
|
||||
Expect(result.BlockHash).To(Equal(blockHash))
|
||||
Expect(result.Row).To(Equal(expectedRow))
|
||||
AssertVariable(result, blockNumber, blockHash, expectedRow)
|
||||
})
|
||||
|
||||
It("persists a vow Sin", func() {
|
||||
@ -103,16 +89,11 @@ var _ = Describe("Vow storage repository test", func() {
|
||||
err = repo.Create(blockNumber, blockHash, vow.SinMetadata, expectedSow)
|
||||
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
type VowSin struct {
|
||||
BlockMetadata
|
||||
Sin string
|
||||
}
|
||||
var result VowSin
|
||||
err = db.Get(&result, `SELECT block_number, block_hash, sin from maker.vow_sin`)
|
||||
|
||||
var result VariableRes
|
||||
err = db.Get(&result, `SELECT block_number, block_hash, sin AS value from maker.vow_sin`)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
Expect(result.BlockNumber).To(Equal(blockNumber))
|
||||
Expect(result.BlockHash).To(Equal(blockHash))
|
||||
Expect(result.Sin).To(Equal(expectedSow))
|
||||
AssertVariable(result, blockNumber, blockHash, expectedSow)
|
||||
})
|
||||
|
||||
It("persists a vow woe", func() {
|
||||
@ -121,16 +102,11 @@ var _ = Describe("Vow storage repository test", func() {
|
||||
err = repo.Create(blockNumber, blockHash, vow.WoeMetadata, expectedWoe)
|
||||
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
type VowWoe struct {
|
||||
BlockMetadata
|
||||
Woe string
|
||||
}
|
||||
var result VowWoe
|
||||
err = db.Get(&result, `SELECT block_number, block_hash, woe from maker.vow_woe`)
|
||||
|
||||
var result VariableRes
|
||||
err = db.Get(&result, `SELECT block_number, block_hash, woe AS value from maker.vow_woe`)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
Expect(result.BlockNumber).To(Equal(blockNumber))
|
||||
Expect(result.BlockHash).To(Equal(blockHash))
|
||||
Expect(result.Woe).To(Equal(expectedWoe))
|
||||
AssertVariable(result, blockNumber, blockHash, expectedWoe)
|
||||
})
|
||||
|
||||
It("persists a vow Ash", func() {
|
||||
@ -139,16 +115,11 @@ var _ = Describe("Vow storage repository test", func() {
|
||||
err = repo.Create(blockNumber, blockHash, vow.AshMetadata, expectedAsh)
|
||||
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
type VowAsh struct {
|
||||
BlockMetadata
|
||||
Ash string
|
||||
}
|
||||
var result VowAsh
|
||||
err = db.Get(&result, `SELECT block_number, block_hash, ash from maker.vow_ash`)
|
||||
|
||||
var result VariableRes
|
||||
err = db.Get(&result, `SELECT block_number, block_hash, ash AS value from maker.vow_ash`)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
Expect(result.BlockNumber).To(Equal(blockNumber))
|
||||
Expect(result.BlockHash).To(Equal(blockHash))
|
||||
Expect(result.Ash).To(Equal(expectedAsh))
|
||||
AssertVariable(result, blockNumber, blockHash, expectedAsh)
|
||||
})
|
||||
|
||||
It("persists a vow Wait", func() {
|
||||
@ -157,16 +128,11 @@ var _ = Describe("Vow storage repository test", func() {
|
||||
err = repo.Create(blockNumber, blockHash, vow.WaitMetadata, expectedWait)
|
||||
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
type VowWait struct {
|
||||
BlockMetadata
|
||||
Wait string
|
||||
}
|
||||
var result VowWait
|
||||
err = db.Get(&result, `SELECT block_number, block_hash, wait from maker.vow_wait`)
|
||||
|
||||
var result VariableRes
|
||||
err = db.Get(&result, `SELECT block_number, block_hash, wait AS value from maker.vow_wait`)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
Expect(result.BlockNumber).To(Equal(blockNumber))
|
||||
Expect(result.BlockHash).To(Equal(blockHash))
|
||||
Expect(result.Wait).To(Equal(expectedWait))
|
||||
AssertVariable(result, blockNumber, blockHash, expectedWait)
|
||||
})
|
||||
|
||||
It("persists a vow Bump", func() {
|
||||
@ -175,16 +141,11 @@ var _ = Describe("Vow storage repository test", func() {
|
||||
err = repo.Create(blockNumber, blockHash, vow.BumpMetadata, expectedBump)
|
||||
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
type VowBump struct {
|
||||
BlockMetadata
|
||||
Bump string
|
||||
}
|
||||
var result VowBump
|
||||
err = db.Get(&result, `SELECT block_number, block_hash, bump from maker.vow_bump`)
|
||||
|
||||
var result VariableRes
|
||||
err = db.Get(&result, `SELECT block_number, block_hash, bump AS value from maker.vow_bump`)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
Expect(result.BlockNumber).To(Equal(blockNumber))
|
||||
Expect(result.BlockHash).To(Equal(blockHash))
|
||||
Expect(result.Bump).To(Equal(expectedBump))
|
||||
AssertVariable(result, blockNumber, blockHash, expectedBump)
|
||||
})
|
||||
|
||||
It("persists a vow Sump", func() {
|
||||
@ -193,16 +154,11 @@ var _ = Describe("Vow storage repository test", func() {
|
||||
err = repo.Create(blockNumber, blockHash, vow.SumpMetadata, expectedSump)
|
||||
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
type VowSump struct {
|
||||
BlockMetadata
|
||||
Sump string
|
||||
}
|
||||
var result VowSump
|
||||
err = db.Get(&result, `SELECT block_number, block_hash, sump from maker.vow_sump`)
|
||||
|
||||
var result VariableRes
|
||||
err = db.Get(&result, `SELECT block_number, block_hash, sump AS value from maker.vow_sump`)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
Expect(result.BlockNumber).To(Equal(blockNumber))
|
||||
Expect(result.BlockHash).To(Equal(blockHash))
|
||||
Expect(result.Sump).To(Equal(expectedSump))
|
||||
AssertVariable(result, blockNumber, blockHash, expectedSump)
|
||||
})
|
||||
|
||||
It("persists a vow Hump", func() {
|
||||
@ -211,20 +167,10 @@ var _ = Describe("Vow storage repository test", func() {
|
||||
err = repo.Create(blockNumber, blockHash, vow.HumpMetadata, expectedHump)
|
||||
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
type VowHump struct {
|
||||
BlockMetadata
|
||||
Hump string
|
||||
}
|
||||
var result VowHump
|
||||
err = db.Get(&result, `SELECT block_number, block_hash, hump from maker.vow_hump`)
|
||||
|
||||
var result VariableRes
|
||||
err = db.Get(&result, `SELECT block_number, block_hash, hump AS value from maker.vow_hump`)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
Expect(result.BlockNumber).To(Equal(blockNumber))
|
||||
Expect(result.BlockHash).To(Equal(blockHash))
|
||||
Expect(result.Hump).To(Equal(expectedHump))
|
||||
AssertVariable(result, blockNumber, blockHash, expectedHump)
|
||||
})
|
||||
})
|
||||
|
||||
type BlockMetadata struct {
|
||||
BlockNumber int `db:"block_number"`
|
||||
BlockHash string `db:"block_hash"`
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user