Пример #1
0
Файл: CLI.ts Проект: HansS/tsd
	function assertCLIResult(result:xm.RunCLIResult, test, info:helper.TestInfo, args):void {
		assert.isObject(result, 'result');
		assert.strictEqual(result.code, 0, 'result.code');
		assert.operator(result.stdout.length, '>=', 0, 'result.stdout.length');

		var stdout = trimHeader(result.stdout.toString('utf8'));
		var stderr = trimHeader(result.stderr.toString('utf8'));

		fs.writeFileSync(info.stdoutFile, stdout, 'utf8');
		if (result.stderr.length > 0) {
			fs.writeFileSync(info.stderrFile, stderr, 'utf8');
		}
		if (result.error) {
			xm.file.writeJSONSync(info.errorFile, result.error);
		}

		var stdoutExpect = fs.readFileSync(info.stdoutExpect, 'utf8');
		assert.operator(stdoutExpect.length, '>=', 0, 'stdoutExpect.length');

		helper.longAssert(stdout, stdoutExpect, 'result.stdout');

		if (fs.existsSync(info.stderrExpect)) {
			var stderrExpect = fs.readFileSync(info.stderrExpect, 'utf8');
			helper.longAssert(stderr, stderrExpect, 'result.stderr');
		}
		if (fs.existsSync(info.errorExpect)) {
			var errorExpect = xm.file.readJSONSync(info.errorExpect);
			assert.jsonOf(result.error, errorExpect, 'result.error');
		}
	}
Пример #2
0
	export function assertSelection(selection:tsd.Selection, values:any, message:string) {
		assert.isObject(selection, message + ': selection');
		assert.isObject(values, message + ': values');
		assert.instanceOf(selection, tsd.Selection, message + ': selection');

		if (values.selection) {
			helper.assertDefVersionArray(selection.selection, values.selection, message + ': selection');
		}
		if (values.definitions) {
			helper.assertDefArray(selection.definitions, values.definitions, message + ': definitions');
		}
		if (values.error) {
			assert.jsonOf(values.error, selection.error, message + ': error');
		}
	}
Пример #3
0
			}).then((first) => {
				assert.ok(first, 'first data');
				assert.isObject(first, 'first data');
				assert.strictEqual(first.sha, expectedSha, 'first.sha vs expectedSha');

				assert.jsonSchema(first, metaFields, 'first meta');
				fixMeta(first.meta);
				assert.jsonOf(expectedJson, first, 'first vs expectedJson');

				var firstBuffer = git.GitUtil.decodeBlobJson(first);
				assert.instanceOf(firstBuffer, Buffer, 'buffer');

				var firstSha = git.GitUtil.blobShaHex(firstBuffer);
				assert.strictEqual(firstSha, expectedSha, 'firstSha vs expected');

				// get again, should be cached
				return repo.api.getBlob(expectedSha).progress((note:any) => {
					notes.push(note);
				}).then((second) => {
					assert.ok(second, 'second data');
					assert.isObject(second, 'second data');
					assert.strictEqual(second.sha, expectedSha, 'second.sha vs expectedSha');

					var secondBuffer = git.GitUtil.decodeBlobJson(first);
					assert.instanceOf(secondBuffer, Buffer, 'buffer');
					var secondSha = git.GitUtil.blobShaHex(secondBuffer);
					assert.strictEqual(secondSha, expectedSha, 'secondSha vs expected');

					helper.assertNotes(notes, [
						{
							message: /^remote: /,
							code: 'http 200'
						},
						{
							message: /^local: /,
							code: null
						}
					], 'second');
				});
			});