| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | |
| 2 // for details. All rights reserved. Use of this source code is governed by a | |
| 3 // BSD-style license that can be found in the LICENSE file. | |
| 4 | |
| 5 #library('pub_tests'); | |
| 6 | |
| 7 #import('dart:io'); | |
| 8 | |
| 9 #import('test_pub.dart'); | |
| 10 #import('../../../pkg/unittest/unittest.dart'); | |
| 11 | |
| 12 main() { | |
| 13 test('fails gracefully if the url does not resolve', () { | |
| 14 dir(appPath, [ | |
| 15 pubspec({ | |
| 16 "name": "myapp", | |
| 17 "dependencies": { | |
| 18 "foo": { | |
| 19 "hosted": { | |
| 20 "name": "foo", | |
| 21 "url": "http://pub.invalid" | |
| 22 } | |
| 23 } | |
| 24 } | |
| 25 }) | |
| 26 ]).scheduleCreate(); | |
| 27 | |
| 28 schedulePub(args: ['update'], | |
| 29 error: const RegExp('Could not resolve URL "http://pub.invalid".'), | |
| 30 exitCode: 1); | |
| 31 | |
| 32 run(); | |
| 33 }); | |
| 34 | |
| 35 test('fails gracefully if the package does not exist', () { | |
| 36 servePackages([]); | |
| 37 | |
| 38 appDir([dependency("foo", "1.2.3")]).scheduleCreate(); | |
| 39 | |
| 40 schedulePub(args: ['update'], | |
| 41 error: const RegExp('Could not find package "foo" on ' | |
| 42 'http://localhost:'), | |
| 43 exitCode: 1); | |
| 44 | |
| 45 run(); | |
| 46 }); | |
| 47 | |
| 48 test("updates one locked pub server package's dependencies if it's " | |
| 49 "necessary", () { | |
| 50 servePackages([ | |
| 51 package("foo", "1.0.0", [dependency("foo-dep")]), | |
| 52 package("foo-dep", "1.0.0") | |
| 53 ]); | |
| 54 | |
| 55 appDir([dependency("foo")]).scheduleCreate(); | |
| 56 | |
| 57 schedulePub(args: ['install'], | |
| 58 output: const RegExp(r"Dependencies installed!$")); | |
| 59 | |
| 60 packagesDir({ | |
| 61 "foo": "1.0.0", | |
| 62 "foo-dep": "1.0.0" | |
| 63 }).scheduleValidate(); | |
| 64 | |
| 65 servePackages([ | |
| 66 package("foo", "2.0.0", [dependency("foo-dep", ">1.0.0")]), | |
| 67 package("foo-dep", "2.0.0") | |
| 68 ]); | |
| 69 | |
| 70 schedulePub(args: ['update', 'foo'], | |
| 71 output: const RegExp(r"Dependencies updated!$")); | |
| 72 | |
| 73 packagesDir({ | |
| 74 "foo": "2.0.0", | |
| 75 "foo-dep": "2.0.0" | |
| 76 }).scheduleValidate(); | |
| 77 | |
| 78 run(); | |
| 79 }); | |
| 80 | |
| 81 test("updates a locked package's dependers in order to get it to max " | |
| 82 "version", () { | |
| 83 servePackages([ | |
| 84 package("foo", "1.0.0", [dependency("bar", "<2.0.0")]), | |
| 85 package("bar", "1.0.0") | |
| 86 ]); | |
| 87 | |
| 88 appDir([dependency("foo"), dependency("bar")]).scheduleCreate(); | |
| 89 | |
| 90 schedulePub(args: ['install'], | |
| 91 output: const RegExp(r"Dependencies installed!$")); | |
| 92 | |
| 93 packagesDir({ | |
| 94 "foo": "1.0.0", | |
| 95 "bar": "1.0.0" | |
| 96 }).scheduleValidate(); | |
| 97 | |
| 98 servePackages([ | |
| 99 package("foo", "2.0.0", [dependency("bar", "<3.0.0")]), | |
| 100 package("bar", "2.0.0") | |
| 101 ]); | |
| 102 | |
| 103 schedulePub(args: ['update', 'bar'], | |
| 104 output: const RegExp(r"Dependencies updated!$")); | |
| 105 | |
| 106 packagesDir({ | |
| 107 "foo": "2.0.0", | |
| 108 "bar": "2.0.0" | |
| 109 }).scheduleValidate(); | |
| 110 | |
| 111 run(); | |
| 112 }); | |
| 113 | |
| 114 test("removes a dependency that's been removed from the pubspec", () { | |
| 115 servePackages([ | |
| 116 package("foo", "1.0.0"), | |
| 117 package("bar", "1.0.0") | |
| 118 ]); | |
| 119 | |
| 120 appDir([dependency("foo"), dependency("bar")]).scheduleCreate(); | |
| 121 | |
| 122 schedulePub(args: ['update'], | |
| 123 output: const RegExp(r"Dependencies updated!$")); | |
| 124 | |
| 125 packagesDir({ | |
| 126 "foo": "1.0.0", | |
| 127 "bar": "1.0.0" | |
| 128 }).scheduleValidate(); | |
| 129 | |
| 130 appDir([dependency("foo")]).scheduleCreate(); | |
| 131 | |
| 132 schedulePub(args: ['update'], | |
| 133 output: const RegExp(r"Dependencies updated!$")); | |
| 134 | |
| 135 packagesDir({ | |
| 136 "foo": "1.0.0", | |
| 137 "bar": null | |
| 138 }).scheduleValidate(); | |
| 139 | |
| 140 run(); | |
| 141 }); | |
| 142 | |
| 143 test("removes a transitive dependency that's no longer depended on", () { | |
| 144 servePackages([ | |
| 145 package("foo", "1.0.0", [dependency("shared-dep")]), | |
| 146 package("bar", "1.0.0", [ | |
| 147 dependency("shared-dep"), | |
| 148 dependency("bar-dep") | |
| 149 ]), | |
| 150 package("shared-dep", "1.0.0"), | |
| 151 package("bar-dep", "1.0.0") | |
| 152 ]); | |
| 153 | |
| 154 appDir([dependency("foo"), dependency("bar")]).scheduleCreate(); | |
| 155 | |
| 156 schedulePub(args: ['update'], | |
| 157 output: const RegExp(r"Dependencies updated!$")); | |
| 158 | |
| 159 packagesDir({ | |
| 160 "foo": "1.0.0", | |
| 161 "bar": "1.0.0", | |
| 162 "shared-dep": "1.0.0", | |
| 163 "bar-dep": "1.0.0", | |
| 164 }).scheduleValidate(); | |
| 165 | |
| 166 appDir([dependency("foo")]).scheduleCreate(); | |
| 167 | |
| 168 schedulePub(args: ['update'], | |
| 169 output: const RegExp(r"Dependencies updated!$")); | |
| 170 | |
| 171 packagesDir({ | |
| 172 "foo": "1.0.0", | |
| 173 "bar": null, | |
| 174 "shared-dep": "1.0.0", | |
| 175 "bar-dep": null, | |
| 176 }).scheduleValidate(); | |
| 177 | |
| 178 run(); | |
| 179 }); | |
| 180 | |
| 181 test("updates dependencies whose constraints have been removed", () { | |
| 182 servePackages([ | |
| 183 package("foo", "1.0.0", [dependency("shared-dep")]), | |
| 184 package("bar", "1.0.0", [dependency("shared-dep", "<2.0.0")]), | |
| 185 package("shared-dep", "1.0.0"), | |
| 186 package("shared-dep", "2.0.0") | |
| 187 ]); | |
| 188 | |
| 189 appDir([dependency("foo"), dependency("bar")]).scheduleCreate(); | |
| 190 | |
| 191 schedulePub(args: ['update'], | |
| 192 output: const RegExp(r"Dependencies updated!$")); | |
| 193 | |
| 194 packagesDir({ | |
| 195 "foo": "1.0.0", | |
| 196 "bar": "1.0.0", | |
| 197 "shared-dep": "1.0.0" | |
| 198 }).scheduleValidate(); | |
| 199 | |
| 200 appDir([dependency("foo")]).scheduleCreate(); | |
| 201 | |
| 202 schedulePub(args: ['update'], | |
| 203 output: const RegExp(r"Dependencies updated!$")); | |
| 204 | |
| 205 packagesDir({ | |
| 206 "foo": "1.0.0", | |
| 207 "bar": null, | |
| 208 "shared-dep": "2.0.0" | |
| 209 }).scheduleValidate(); | |
| 210 | |
| 211 run(); | |
| 212 }); | |
| 213 } | |
| OLD | NEW |