• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

sphereio / sphere-node-sdk / 1325 / 1
98%
master: 98%

Build:
DEFAULT BRANCH: master
Ran 07 Dec 2018 10:40AM UTC
Files 45
Run time 924min
Badge
Embed ▾
README BADGES
x

If you need to use a raster PNG badge, change the '.svg' to '.png' in the link

Markdown

Textile

RDoc

HTML

Rst

07 Dec 2018 10:37AM UTC coverage: 97.612% (-0.04%) from 97.649%
1325.1

push

travis-ci

daern91
fix(product-sync): fix matching variants (#273)

#### Summary
Fix how we match variants.

#### Description
Originally, we were matching variants in a single loop by comparing id, sku or key.
Because we used id as a primary matching condition, there was happening, that we matched variants with the same ids but with different skus which later failed due to a duplicate slug error.

For example when syncing these two products:
```js
// existing product
{
	masterVariant: {
		id: 1,
		sku: "sku1"
	},
	variants: [{
		id: 2,
		sku: "sku3"
	}, {
		id: 3,
		sku: "sku2"
	}]
}
// and new product
{
	masterVariant: {
		id: 1,
		sku: "sku1"
	},
	variants: [{
		id: 2,
		sku: "sku2"
	}, {
		id: 3,
		sku: "sku3"
	}]
}
```
It would match variants using id and generate update actions:
```js
[{
	action: "setSku",
	variantId: 2,
	sku: "sku2"
}, {
	action: "setSku",
	variantId: 3,
	sku: "sku3"
}]
```
Which would fail because we can't set `sku2` to the first variant because it already exists. Therefore we should match by skus, then by keys and then, as a fallback, by id.

#### Todo

- Tests
    - [x] Unit
    - [ ] Integration
    - [ ] Acceptance
- [ ] Documentation
<!-- Two persons should review a PR, don't forget to assign them. -->

792 of 919 branches covered (86.18%)

2044 of 2094 relevant lines covered (97.61%)

167.27 hits per line

Source Files on job 1325.1
  • Tree
  • List 0
  • Changed 4
  • Source Changed 2
  • Coverage Changed 3
Coverage ∆ File Lines Relevant Covered Missed Hits/Line Branch Hits Branch Misses
  • Back to Build 1239
  • Travis Job 1325.1
  • 2edc59a6 on github
  • Prev Job for on master (#1311.1)
  • Next Job for on master (#1326.1)
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc