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

sphereio / sphere-node-sdk / 1325
98%

Build:
DEFAULT BRANCH: master
Ran 07 Dec 2018 10:40AM UTC
Jobs 2
Files 45
Run time 1208min
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

pending completion
1325

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%)

334.54 hits per line

Jobs
ID Job ID Ran Files Coverage
1 1325.1 07 Dec 2018 10:40AM UTC 0
97.61
Travis Job 1325.1
2 1325.2 07 Dec 2018 10:43AM UTC 0
97.61
Travis Job 1325.2
Source Files on build 1325
Detailed source file information is not available for this build.
  • Back to Repo
  • Travis Build #1325
  • 2edc59a6 on github
  • Prev Build on master (#1311)
  • Next Build on master (#1326)
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