Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(155)

Unified Diff: test/backend/metadata_test.dart

Issue 1405633004: feature: tag tests; choose tags on command line Base URL: git@github.com:yjbanov/test.git@tags
Patch Set: address comments Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « test/backend/declarer_test.dart ('k') | test/runner/tag_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/backend/metadata_test.dart
diff --git a/test/backend/metadata_test.dart b/test/backend/metadata_test.dart
index ab14a74bde550a52a9b895f5b73e4085b75c0a37..acb88f349481467469cf30b04161029fb2080566 100644
--- a/test/backend/metadata_test.dart
+++ b/test/backend/metadata_test.dart
@@ -9,6 +9,74 @@ import 'package:test/src/frontend/skip.dart';
import 'package:test/test.dart';
void main() {
+ group("Metadata", () {
+ void expectTags(tags, expected) {
+ expect(new Metadata.parse(tags: tags).tags, unorderedEquals(expected));
+
+ if (tags == null || tags is Iterable) {
+ expect(new Metadata(tags: tags).tags, unorderedEquals(expected));
+ }
+ }
+
+ void expectTagsError(tags) {
+ expect(() => new Metadata(tags: tags), throwsArgumentError);
+ expect(() => new Metadata.parse(tags: tags), throwsArgumentError);
+ }
+
+ test("takes no tags", () {
+ expectTags(null, []);
+ expectTags("", []);
+ expectTags([], []);
+ });
+
+ test("takes some tags as Iterable", () {
+ var tags = ["a", "b"];
+ expectTags(tags, tags);
+ expectTags(new Set.from(tags), tags);
+ });
+
+ test("takes some tags as String", () {
+ expectTags("a", ["a"]);
+ });
+
+ test("parse refuses bad tag types", () {
+ expect(() => new Metadata.parse(tags: 1), throwsArgumentError);
+ });
+
+ test("refuses non-String tag names", () {
+ expectTagsError([1]);
+ expectTagsError([null]);
+ });
+
+ test("refuses blank tag names", () {
+ expectTagsError([""]);
+ });
+
+ test("merges tags by computing the union of the two tag sets", () {
+ var merged = new Metadata(tags: ["a", "b"])
+ .merge(new Metadata(tags: ["b", "c"]));
+ expect(merged.tags, unorderedEquals(["a", "b", "c"]));
+ });
+
+ test("serializes tags to a List", () {
+ var serialized = new Metadata(tags: ["a", "b"]).serialize()['tags'];
+ expect(serialized, new isInstanceOf<List>());
+ expect(serialized, ["a", "b"]);
+ });
+
+ group('deserialize', () {
+ test('deserializes tags', () {
+ var serialized = {
+ "tags": ['a', 'b'],
+ "timeout": "none",
+ "onPlatform": [],
+ };
+ expect(new Metadata.deserialize(serialized).tags,
+ unorderedEquals(['a', 'b']));
+ });
+ });
+ });
+
group("onPlatform", () {
test("parses a valid map", () {
var metadata = new Metadata.parse(onPlatform: {
« no previous file with comments | « test/backend/declarer_test.dart ('k') | test/runner/tag_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698