Skip to content

Commit

Permalink
test(yarn fixtures) initial edge case fixture structure example for y…
Browse files Browse the repository at this point in the history
…arn tooling (#323)
  • Loading branch information
microsoftly authored Oct 5, 2018
1 parent 3c243bc commit 4c51b77
Show file tree
Hide file tree
Showing 12 changed files with 43 additions and 0 deletions.
14 changes: 14 additions & 0 deletions buildtools/yarn/parse_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,20 @@ func TestSimpleLockfile(t *testing.T) {
AssertDeps(t, deps.Transitive, "chai", "4.1.2")
}

func TestTransDepNameAndRevisionCollisionWithProdDirectDep(t *testing.T) {
testPathBase := filepath.Join("testdata", "trans_dep_name_and_revision_collision_with_prod_direct_dep")
deps, err := yarn.FromProject(filepath.Join(testPathBase, "package.json"), filepath.Join(testPathBase, "yarn.lock"))
assert.NoError(t, err)

assert.Len(t, deps.Direct, 1)
assert.Len(t, deps.Transitive, 1)

assert.Equal(t, "a", deps.Direct[0].Target)
assert.Equal(t, "1.0.1", deps.Direct[0].Resolved.Revision)

AssertDeps(t, deps.Transitive, "a", "1.0.1")
}

func AssertDeps(t *testing.T, transitiveDeps map[pkg.ID]pkg.Package, name, revision string) {
for pkgID, _ := range transitiveDeps {
if pkgID.Name == name && pkgID.Revision == revision {
Expand Down
Empty file.
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
### prod deps
* a@^1.0.0 -> 1.0.1

### dev deps
* b@^2.0.0 -> 2.0.2
* a^1.0.0 -> 1.0.1
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"name": "testdata",
"version": "1.0.0",
"dependencies": {
"a":"^1.0.0"
},
"devDependencies": {
"b":"^2.0.0"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
# yarn lockfile v1


a@^1.0.0:
version "1.0.1"
resolved "someurl"

b@^2.0.0:
version "2.0.1"
resolved "someurl"
dependencies:
a "^1.0.0"
Empty file.
Empty file.
Empty file.
Empty file.

0 comments on commit 4c51b77

Please sign in to comment.