update tests and import order per PR feedback
This commit is contained in:
parent
4ca7c10f92
commit
adc7c47244
@ -9,5 +9,6 @@ CREATE TABLE maker.bite (
|
|||||||
tab NUMERIC,
|
tab NUMERIC,
|
||||||
flip VARCHAR,
|
flip VARCHAR,
|
||||||
tx_idx INTEGER NOT NUll,
|
tx_idx INTEGER NOT NUll,
|
||||||
raw_log JSONB
|
raw_log JSONB,
|
||||||
|
UNIQUE (header_id, tx_idx)
|
||||||
)
|
)
|
@ -701,6 +701,14 @@ ALTER TABLE ONLY public.transactions ALTER COLUMN id SET DEFAULT nextval('public
|
|||||||
ALTER TABLE ONLY public.watched_contracts ALTER COLUMN contract_id SET DEFAULT nextval('public.watched_contracts_contract_id_seq'::regclass);
|
ALTER TABLE ONLY public.watched_contracts ALTER COLUMN contract_id SET DEFAULT nextval('public.watched_contracts_contract_id_seq'::regclass);
|
||||||
|
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Name: bite bite_header_id_tx_idx_key; Type: CONSTRAINT; Schema: maker; Owner: -
|
||||||
|
--
|
||||||
|
|
||||||
|
ALTER TABLE ONLY maker.bite
|
||||||
|
ADD CONSTRAINT bite_header_id_tx_idx_key UNIQUE (header_id, tx_idx);
|
||||||
|
|
||||||
|
|
||||||
--
|
--
|
||||||
-- Name: bite bite_pkey; Type: CONSTRAINT; Schema: maker; Owner: -
|
-- Name: bite bite_pkey; Type: CONSTRAINT; Schema: maker; Owner: -
|
||||||
--
|
--
|
||||||
|
@ -48,6 +48,7 @@ func (BiteConverter) ToEntity(contractAddress string, contractAbi string, ethLog
|
|||||||
}
|
}
|
||||||
|
|
||||||
entity.Raw = ethLog
|
entity.Raw = ethLog
|
||||||
|
entity.TransactionIndex = ethLog.TxIndex
|
||||||
|
|
||||||
return entity, nil
|
return entity, nil
|
||||||
}
|
}
|
||||||
|
@ -17,14 +17,15 @@
|
|||||||
package bite_test
|
package bite_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
. "github.com/onsi/ginkgo"
|
"math/big"
|
||||||
. "github.com/onsi/gomega"
|
|
||||||
|
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
|
||||||
"github.com/ethereum/go-ethereum/core/types"
|
"github.com/ethereum/go-ethereum/core/types"
|
||||||
"github.com/vulcanize/vulcanizedb/pkg/transformers/bite"
|
"github.com/vulcanize/vulcanizedb/pkg/transformers/bite"
|
||||||
"github.com/vulcanize/vulcanizedb/pkg/transformers/test_data"
|
"github.com/vulcanize/vulcanizedb/pkg/transformers/test_data"
|
||||||
"math/big"
|
|
||||||
|
. "github.com/onsi/ginkgo"
|
||||||
|
. "github.com/onsi/gomega"
|
||||||
)
|
)
|
||||||
|
|
||||||
var _ = Describe("Bite Converter", func() {
|
var _ = Describe("Bite Converter", func() {
|
||||||
@ -42,6 +43,8 @@ var _ = Describe("Bite Converter", func() {
|
|||||||
Expect(entity.Tab).To(Equal(test_data.BiteEntity.Tab))
|
Expect(entity.Tab).To(Equal(test_data.BiteEntity.Tab))
|
||||||
Expect(entity.Flip).To(Equal(test_data.BiteEntity.Flip))
|
Expect(entity.Flip).To(Equal(test_data.BiteEntity.Flip))
|
||||||
Expect(entity.IArt).To(Equal(test_data.BiteEntity.IArt))
|
Expect(entity.IArt).To(Equal(test_data.BiteEntity.IArt))
|
||||||
|
Expect(entity.TransactionIndex).To(Equal(test_data.BiteEntity.TransactionIndex))
|
||||||
|
Expect(entity.Raw).To(Equal(test_data.BiteEntity.Raw))
|
||||||
})
|
})
|
||||||
|
|
||||||
It("returns an error if converting log to entity fails", func() {
|
It("returns an error if converting log to entity fails", func() {
|
||||||
@ -63,10 +66,10 @@ var _ = Describe("Bite Converter", func() {
|
|||||||
|
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
Expect(model).To(Equal(test_data.BiteModel))
|
Expect(model).To(Equal(test_data.BiteModel))
|
||||||
|
Expect(model.TransactionIndex).To(Equal(test_data.BiteModel.TransactionIndex))
|
||||||
})
|
})
|
||||||
|
|
||||||
It("handles nil values", func() {
|
It("handles nil values", func() {
|
||||||
emptyEntity.Id = big.NewInt(1)
|
|
||||||
emptyLog, err := json.Marshal(types.Log{})
|
emptyLog, err := json.Marshal(types.Log{})
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
expectedModel := bite.BiteModel{
|
expectedModel := bite.BiteModel{
|
||||||
|
@ -64,7 +64,20 @@ var _ = Describe("Bite repository", func() {
|
|||||||
err = biteRepository.Create(headerID, test_data.BiteModel)
|
err = biteRepository.Create(headerID, test_data.BiteModel)
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
|
|
||||||
err = biteRepository.Create(headerID, test_data.BiteModel)
|
var anotherBiteModel = bite.BiteModel{
|
||||||
|
Id: "11",
|
||||||
|
Ilk: test_data.BiteModel.Ilk,
|
||||||
|
Lad: test_data.BiteModel.Lad,
|
||||||
|
Ink: test_data.BiteModel.Ink,
|
||||||
|
Art: test_data.BiteModel.Art,
|
||||||
|
Tab: test_data.BiteModel.Tab,
|
||||||
|
Flip: test_data.BiteModel.Flip,
|
||||||
|
IArt: test_data.BiteModel.IArt,
|
||||||
|
TransactionIndex: test_data.BiteModel.TransactionIndex,
|
||||||
|
Raw: test_data.BiteModel.Raw,
|
||||||
|
}
|
||||||
|
|
||||||
|
err = biteRepository.Create(headerID, anotherBiteModel)
|
||||||
|
|
||||||
Expect(err).To(HaveOccurred())
|
Expect(err).To(HaveOccurred())
|
||||||
Expect(err.Error()).To(ContainSubstring("pq: duplicate key value violates unique constraint"))
|
Expect(err.Error()).To(ContainSubstring("pq: duplicate key value violates unique constraint"))
|
||||||
|
Loading…
Reference in New Issue
Block a user