4f295b9aec
* Use shared repo tests for vat_init * Use shared methods in vat_init repository * Use shared repo tests for vat_move * Use shared methods in vat_move repository * Use shared repo tests for vat_slip * Use shared methods in vat_slip repository * Use shared repo tests for vat_toll * Use shared methods in vat_toll repository * Use shared methods in vat_tune repository * Use shared repo tests for vow_flog (+small namespace fix) * Use shared methods in vow_flog repository * Go vet + tiny oopsie
81 lines
2.8 KiB
Go
81 lines
2.8 KiB
Go
package vat_slip_test
|
|
|
|
import (
|
|
. "github.com/onsi/ginkgo"
|
|
. "github.com/onsi/gomega"
|
|
"github.com/vulcanize/vulcanizedb/pkg/transformers/shared/constants"
|
|
"github.com/vulcanize/vulcanizedb/pkg/transformers/test_data/shared_behaviors"
|
|
|
|
"github.com/vulcanize/vulcanizedb/pkg/datastore/postgres"
|
|
"github.com/vulcanize/vulcanizedb/pkg/datastore/postgres/repositories"
|
|
"github.com/vulcanize/vulcanizedb/pkg/fakes"
|
|
"github.com/vulcanize/vulcanizedb/pkg/transformers/test_data"
|
|
"github.com/vulcanize/vulcanizedb/pkg/transformers/vat_slip"
|
|
"github.com/vulcanize/vulcanizedb/test_config"
|
|
)
|
|
|
|
var _ = Describe("Vat slip repository", func() {
|
|
var (
|
|
db *postgres.DB
|
|
repository vat_slip.VatSlipRepository
|
|
)
|
|
|
|
BeforeEach(func() {
|
|
db = test_config.NewTestDB(test_config.NewTestNode())
|
|
test_config.CleanTestDB(db)
|
|
repository = vat_slip.VatSlipRepository{}
|
|
repository.SetDB(db)
|
|
})
|
|
|
|
Describe("Create", func() {
|
|
modelWithDifferentLogIdx := test_data.VatSlipModel
|
|
modelWithDifferentLogIdx.LogIndex++
|
|
inputs := shared_behaviors.CreateBehaviorInputs{
|
|
CheckedHeaderColumnName: constants.VatSlipChecked,
|
|
LogEventTableName: "maker.vat_slip",
|
|
TestModel: test_data.VatSlipModel,
|
|
ModelWithDifferentLogIdx: modelWithDifferentLogIdx,
|
|
Repository: &repository,
|
|
}
|
|
|
|
shared_behaviors.SharedRepositoryCreateBehaviors(&inputs)
|
|
|
|
It("adds a vat slip event", func() {
|
|
headerRepository := repositories.NewHeaderRepository(db)
|
|
headerID, err := headerRepository.CreateOrUpdateHeader(fakes.FakeHeader)
|
|
Expect(err).NotTo(HaveOccurred())
|
|
|
|
err = repository.Create(headerID, []interface{}{test_data.VatSlipModel})
|
|
Expect(err).NotTo(HaveOccurred())
|
|
|
|
var dbVatSlip vat_slip.VatSlipModel
|
|
err = db.Get(&dbVatSlip, `SELECT ilk, guy, rad, tx_idx, log_idx, raw_log FROM maker.vat_slip WHERE header_id = $1`, headerID)
|
|
Expect(err).NotTo(HaveOccurred())
|
|
Expect(dbVatSlip.Ilk).To(Equal(test_data.VatSlipModel.Ilk))
|
|
Expect(dbVatSlip.Guy).To(Equal(test_data.VatSlipModel.Guy))
|
|
Expect(dbVatSlip.Rad).To(Equal(test_data.VatSlipModel.Rad))
|
|
Expect(dbVatSlip.TransactionIndex).To(Equal(test_data.VatSlipModel.TransactionIndex))
|
|
Expect(dbVatSlip.LogIndex).To(Equal(test_data.VatSlipModel.LogIndex))
|
|
Expect(dbVatSlip.Raw).To(MatchJSON(test_data.VatSlipModel.Raw))
|
|
})
|
|
})
|
|
|
|
Describe("MarkHeaderChecked", func() {
|
|
inputs := shared_behaviors.MarkedHeaderCheckedBehaviorInputs{
|
|
CheckedHeaderColumnName: constants.VatSlipChecked,
|
|
Repository: &repository,
|
|
}
|
|
|
|
shared_behaviors.SharedRepositoryMarkHeaderCheckedBehaviors(&inputs)
|
|
})
|
|
|
|
Describe("MissingHeaders", func() {
|
|
inputs := shared_behaviors.MissingHeadersBehaviorInputs{
|
|
Repository: &repository,
|
|
RepositoryTwo: &vat_slip.VatSlipRepository{},
|
|
}
|
|
|
|
shared_behaviors.SharedRepositoryMissingHeadersBehaviors(&inputs)
|
|
})
|
|
})
|