Skip to content
This repository has been archived by the owner on Mar 28, 2023. It is now read-only.

Commit

Permalink
Fix unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
hoffmabc committed Jun 3, 2020
1 parent f9d8d62 commit 1c34213
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 15 deletions.
4 changes: 2 additions & 2 deletions repo/migrations/Migration012_test.go
Expand Up @@ -605,8 +605,8 @@ var testMigraion012_listingFixtures = []pb.SignedListing{
}

var testMigraion012_listingFixtureHashes = map[string]string{
"slug-4": "QmXC26R4PNnArmVssrviaA4WGxP1zzmx8y2AiybF6hQpRM",
"slug-5": "QmaEUP6zWvZkrWAbVAvcxRiV5Fou8jQnHc4nmarAUVLoQr",
"slug-4": "QmNtQxfK8MwkBCGMFhpxing7Q8hzRfcRWYpPabbEWMx5AQ",
"slug-5": "QmboxBcYU6J7DGTkqVKtKqmCHhbJgGtan8vvputdWZfKRa",
}

var testMigration012_configFixture = `{
Expand Down
2 changes: 1 addition & 1 deletion repo/migrations/Migration027_test.go
Expand Up @@ -37,7 +37,7 @@ func TestUpdateListingHash(t *testing.T) {
// This listing hash is generated using the default IPFS hashing algorithm as of v0.4.19
// If the default hashing algorithm changes at any point in the future you can expect this
// test to fail and it will need to be updated to maintain the functionality of this migration.
expectedListingHash = "Qmdv3oZmVtRuN4tWewsUcBqFYKGD8kaQCq46Yx6rwzEDvH"
expectedListingHash = "QmQa7GzhppHPEALQAko6UC1dZ7UggFq6eaNe1yyKU43vbW"

listing = factory.NewListing(testListingSlug)
m = jsonpb.Marshaler{
Expand Down
27 changes: 18 additions & 9 deletions repo/migrations/Migration028_test.go
Expand Up @@ -3,6 +3,12 @@ package migrations_test
import (
"encoding/base64"
"encoding/json"
crypto "gx/ipfs/QmTW4SdgBWq9GjsBsHeUx8WuGxzhgzAf88UMH2w62PC8yK/go-libp2p-crypto"
"io/ioutil"
"os"
"strconv"
"testing"

"github.com/OpenBazaar/jsonpb"
"github.com/OpenBazaar/openbazaar-go/ipfs"
"github.com/OpenBazaar/openbazaar-go/pb"
Expand All @@ -11,11 +17,6 @@ import (
"github.com/OpenBazaar/openbazaar-go/test/factory"
"github.com/golang/protobuf/proto"
coremock "github.com/ipfs/go-ipfs/core/mock"
crypto "gx/ipfs/QmTW4SdgBWq9GjsBsHeUx8WuGxzhgzAf88UMH2w62PC8yK/go-libp2p-crypto"
"io/ioutil"
"os"
"strconv"
"testing"
)

const (
Expand All @@ -31,7 +32,8 @@ var (
"contractType": "PHYSICAL_GOOD",
"format": "FIXED_PRICE",
"pricingCurrency": "BTC",
"priceModifier": 1
"priceModifier": 1,
"shippingFromCountryCode": "NA"
},
"item": {
"price": 100,
Expand Down Expand Up @@ -71,7 +73,8 @@ var (
"format": "MARKET_PRICE",
"coinType": "BAT",
"coinDivisibility": 8,
"priceModifier": 50
"priceModifier": 50,
"shippingFromCountryCode": "NA"
},
"item": {
"skus": [
Expand All @@ -90,7 +93,8 @@ var (
"metadata": {
"version": 5,
"contractType": "PHYSICAL_GOOD",
"format": "FIXED_PRICE"
"format": "FIXED_PRICE",
"shippingFromCountryCode": "NA"
},
"item": {
"skus": [
Expand Down Expand Up @@ -134,7 +138,8 @@ var (
"contractType": "CRYPTOCURRENCY",
"format": "MARKET_PRICE",
"coinType": "BAT",
"coinDivisibility": 8
"coinDivisibility": 8,
"shippingFromCountryCode": "NA"
},
"item": {
"skus": [
Expand Down Expand Up @@ -240,10 +245,14 @@ func TestMigrateListingsToV5Schema(t *testing.T) {
}

if string(upMigratedListing) != postMigrateListingsToV5Schema_ListingJSON {
t.Log(string(upMigratedListing))
t.Log(postMigrateListingsToV5Schema_ListingJSON)
t.Error("Failed to migrate listing up")
}

if string(upMigratedCryptoListing) != postMigrateListingsToV5Schema_CryptoListingJSON {
t.Log(string(upMigratedCryptoListing))
t.Log(postMigrateListingsToV5Schema_CryptoListingJSON)
t.Error("Failed to migrate crypto listing up")
}

Expand Down
3 changes: 2 additions & 1 deletion test/factory/fixtures/listings/v5-physical-good.json
Expand Up @@ -21,7 +21,8 @@
"LTC",
"ETH"
],
"escrowTimeoutHours": 1
"escrowTimeoutHours": 1,
"shippingFromCountryCode": "NA"
},
"item": {
"title": "ETH - $1",
Expand Down
Expand Up @@ -20,7 +20,8 @@
"BTC",
"BCH"
],
"escrowTimeoutHours": 1080
"escrowTimeoutHours": 1080,
"shippingFromCountryCode": "NA"
},
"item": {
"title": "EXAMPLE FILE 1",
Expand Down
3 changes: 2 additions & 1 deletion test/factory/fixtures/listings/v5-signed-physical-good.json
Expand Up @@ -26,7 +26,8 @@
"divisibility": 2,
"currencyType": "fiat"
},
"escrowTimeoutHours": 1
"escrowTimeoutHours": 1,
"shippingFromCountryCode": "NA"
},
"item": {
"title": "ETH - $1",
Expand Down

0 comments on commit 1c34213

Please sign in to comment.